Skip to content

Commit

Permalink
Merge pull request #337 from nemunaire/fixes
Browse files Browse the repository at this point in the history
Bunch of small fixes
  • Loading branch information
ddvk authored Nov 17, 2024
2 parents 736e2eb + ea127c7 commit cb1e4ea
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
9 changes: 2 additions & 7 deletions internal/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -892,19 +892,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) {
Expand Down
2 changes: 2 additions & 0 deletions internal/email/smtp.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"net/url"
"path/filepath"
"strings"
"time"

log "github.com/sirupsen/logrus"
)
Expand Down Expand Up @@ -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 {
Expand Down
5 changes: 5 additions & 0 deletions internal/storage/fs/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit cb1e4ea

Please sign in to comment.