Skip to content

Commit

Permalink
🔊 Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
Danieloni1 committed May 23, 2024
1 parent 0439e24 commit 5fe12d9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
24 changes: 12 additions & 12 deletions api/r0/upload_async.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@ package r0

import (
"errors"
"io"
"net/http"
"path/filepath"

"github.com/getsentry/sentry-go"
"github.com/h2non/filetype"
"github.com/sirupsen/logrus"
"github.com/t2bot/matrix-media-repo/api/_apimeta"
"github.com/t2bot/matrix-media-repo/api/_responses"
Expand Down Expand Up @@ -58,16 +56,18 @@ func UploadMediaAsync(r *http.Request, rctx rcontext.RequestContext, user _apime
}
}

// GK-CUSTOMIZATION: Check if the file type is supported
buf, _ := io.ReadAll(r.Body)
kind, _ := filetype.Match(buf)
if !isSupportedFileType(kind.Extension) {
return &_responses.ErrorResponse{
Code: common.ErrCodeBadRequest,
Message: "Unsupported file type.",
InternalCode: common.ErrCodeBadRequest,
}
}
// // GK-CUSTOMIZATION: Check if the file type is supported
// buf, _ := io.ReadAll(r.Body)
// kind, _ := filetype.Match(buf)
// rctx.Log.Error("🔊 File type: ", kind)
// if !isSupportedFileType(kind.Extension) {
// rctx.Log.Error("🔊 unsupported file type")
// return &_responses.ErrorResponse{
// Code: common.ErrCodeBadRequest,
// Message: "Unsupported file type.",
// InternalCode: common.ErrCodeBadRequest,
// }
// }

rctx = rctx.LogWithFields(logrus.Fields{
"mediaId": mediaId,
Expand Down
24 changes: 12 additions & 12 deletions api/r0/upload_sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package r0

import (
"errors"
"io"
"net/http"
"path/filepath"
"strconv"

"github.com/getsentry/sentry-go"
"github.com/h2non/filetype"
"github.com/sirupsen/logrus"
"github.com/t2bot/matrix-media-repo/api/_apimeta"
"github.com/t2bot/matrix-media-repo/api/_responses"
Expand All @@ -34,16 +32,18 @@ func UploadMediaSync(r *http.Request, rctx rcontext.RequestContext, user _apimet
}
}

// GK-CUSTOMIZATION: Check if the file type is supported
buf, _ := io.ReadAll(r.Body)
kind, _ := filetype.Match(buf)
if !isSupportedFileType(kind.Extension) {
return &_responses.ErrorResponse{
Code: common.ErrCodeBadRequest,
Message: "Unsupported file type.",
InternalCode: common.ErrCodeBadRequest,
}
}
// // GK-CUSTOMIZATION: Check if the file type is supported
// buf, _ := io.ReadAll(r.Body)
// kind, _ := filetype.Match(buf)
// rctx.Log.Error("🔊 File type: ", kind)
// if !isSupportedFileType(kind.Extension) {
// rctx.Log.Error("🔊 unsupported file type")
// return &_responses.ErrorResponse{
// Code: common.ErrCodeBadRequest,
// Message: "Unsupported file type.",
// InternalCode: common.ErrCodeBadRequest,
// }
// }

rctx = rctx.LogWithFields(logrus.Fields{
"filename": filename,
Expand Down

0 comments on commit 5fe12d9

Please sign in to comment.