From 2c4aa88a1c9140af73a00ec0cb72dc9da79aed27 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 29 Nov 2020 13:45:51 +0100 Subject: [PATCH 1/3] email: Add Date header --- internal/email/smtp.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/internal/email/smtp.go b/internal/email/smtp.go index 4d69b00f..6e3be96c 100644 --- a/internal/email/smtp.go +++ b/internal/email/smtp.go @@ -13,6 +13,7 @@ import ( "net/url" "path/filepath" "strings" + "time" log "github.com/sirupsen/logrus" ) @@ -184,6 +185,7 @@ func (b *Builder) Send(cfg *SMTPConfig) (err error) { msgBuilder := strings.Builder{} //basic email headers + msgBuilder.WriteString(fmt.Sprintf("Date: %s\r\n", time.Now().Format(time.RFC1123Z))) msgBuilder.WriteString(fmt.Sprintf("From: %s\r\n", utf8encode(b.From.String()))) msgBuilder.WriteString(fmt.Sprintf("To: %s\r\n", utf8encode(to))) if b.ReplyTo != nil { From 678f63cfd295bfb2e3402ba9ab5c95c7381ed0c4 Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 17 Nov 2024 12:04:54 +0100 Subject: [PATCH 2/3] Stop flow if request is aborted --- internal/storage/fs/app.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/storage/fs/app.go b/internal/storage/fs/app.go index 7379063e..739ad09f 100644 --- a/internal/storage/fs/app.go +++ b/internal/storage/fs/app.go @@ -144,10 +144,12 @@ func (app *App) downloadBlob(c *gin.Context) { if scope != ReadScope { c.AbortWithStatus(http.StatusForbidden) + return } if blobID == "" { c.AbortWithStatus(http.StatusBadRequest) + return } log.Info("Requestng blob: ", blobID) @@ -185,16 +187,19 @@ func (app *App) uploadBlob(c *gin.Context) { err := VerifyURLParams([]string{uid, blobID, exp, scope}, exp, signature, app.cfg.JWTSecretKey) if err != nil { c.AbortWithStatus(http.StatusForbidden) + return } log.Info(exp, signature) if blobID == "" { c.AbortWithStatus(http.StatusBadRequest) + return } if scope != WriteScope { log.Warn("wrong scope: " + scope) c.AbortWithStatus(http.StatusForbidden) + return } body := c.Request.Body From ea127c730ed18385bcbf5c9e5353b8e582ee7a5c Mon Sep 17 00:00:00 2001 From: Pierre-Olivier Mercier Date: Sun, 17 Nov 2024 13:48:19 +0100 Subject: [PATCH 3/3] PUT /sync/v3/files/:ID doesn't return body --- internal/app/handlers.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/internal/app/handlers.go b/internal/app/handlers.go index 82b18558..b95297d8 100644 --- a/internal/app/handlers.go +++ b/internal/app/handlers.go @@ -898,19 +898,14 @@ func (app *App) blobStorageWrite(c *gin.Context) { hash := c.GetHeader(common.CRC32CHashHeader) log.Debugf("TODO: check/save etc. write file '%s', hash '%s'", fileName, hash) - newgeneration, err := app.blobStorer.StoreBlob(uid, blobID, c.Request.Body, 0) + _, err := app.blobStorer.StoreBlob(uid, blobID, c.Request.Body, 0) if err != nil { log.Error(err) c.AbortWithStatus(http.StatusInternalServerError) return } - //not checked by the client yet, but who knows - crcJSON(c, http.StatusOK, messages.SyncRootV4Response{ - Generation: newgeneration, - Hash: string(blobID), - SchemaVersion: SchemaVersion, - }) + c.Status(http.StatusOK) } func (app *App) integrationsGetMetadata(c *gin.Context) {