aboutsummaryrefslogtreecommitdiff
path: root/mediaapi/routing/download.go
diff options
context:
space:
mode:
authordevonh <devon.dmytro@gmail.com>2023-05-09 22:46:49 +0000
committerGitHub <noreply@github.com>2023-05-09 22:46:49 +0000
commit0489d16f95a3d9f1f5bc532e2060bd2482d7b156 (patch)
treea0573b5a0c21ca563e97abae81e36d66ad14e7d8 /mediaapi/routing/download.go
parenta49c9f01e227aeb12aa2f27d5bf1915453c23a3b (diff)
Move json errors over to gmsl (#3080)
Diffstat (limited to 'mediaapi/routing/download.go')
-rw-r--r--mediaapi/routing/download.go13
1 files changed, 6 insertions, 7 deletions
diff --git a/mediaapi/routing/download.go b/mediaapi/routing/download.go
index bba24327..e9f161a3 100644
--- a/mediaapi/routing/download.go
+++ b/mediaapi/routing/download.go
@@ -30,7 +30,6 @@ import (
"sync"
"unicode"
- "github.com/matrix-org/dendrite/clientapi/jsonerror"
"github.com/matrix-org/dendrite/mediaapi/fileutils"
"github.com/matrix-org/dendrite/mediaapi/storage"
"github.com/matrix-org/dendrite/mediaapi/thumbnailer"
@@ -130,7 +129,7 @@ func Download(
// TODO: Handle the fact we might have started writing the response
dReq.jsonErrorResponse(w, util.JSONResponse{
Code: http.StatusNotFound,
- JSON: jsonerror.NotFound("Failed to download: " + err.Error()),
+ JSON: spec.NotFound("Failed to download: " + err.Error()),
})
return
}
@@ -138,7 +137,7 @@ func Download(
if metadata == nil {
dReq.jsonErrorResponse(w, util.JSONResponse{
Code: http.StatusNotFound,
- JSON: jsonerror.NotFound("File not found"),
+ JSON: spec.NotFound("File not found"),
})
return
}
@@ -168,7 +167,7 @@ func (r *downloadRequest) Validate() *util.JSONResponse {
if !mediaIDRegex.MatchString(string(r.MediaMetadata.MediaID)) {
return &util.JSONResponse{
Code: http.StatusNotFound,
- JSON: jsonerror.NotFound(fmt.Sprintf("mediaId must be a non-empty string using only characters in %v", mediaIDCharacters)),
+ JSON: spec.NotFound(fmt.Sprintf("mediaId must be a non-empty string using only characters in %v", mediaIDCharacters)),
}
}
// Note: the origin will be validated either by comparison to the configured server name of this homeserver
@@ -176,7 +175,7 @@ func (r *downloadRequest) Validate() *util.JSONResponse {
if r.MediaMetadata.Origin == "" {
return &util.JSONResponse{
Code: http.StatusNotFound,
- JSON: jsonerror.NotFound("serverName must be a non-empty string"),
+ JSON: spec.NotFound("serverName must be a non-empty string"),
}
}
@@ -184,7 +183,7 @@ func (r *downloadRequest) Validate() *util.JSONResponse {
if r.ThumbnailSize.Width <= 0 || r.ThumbnailSize.Height <= 0 {
return &util.JSONResponse{
Code: http.StatusBadRequest,
- JSON: jsonerror.Unknown("width and height must be greater than 0"),
+ JSON: spec.Unknown("width and height must be greater than 0"),
}
}
// Default method to scale if not set
@@ -194,7 +193,7 @@ func (r *downloadRequest) Validate() *util.JSONResponse {
if r.ThumbnailSize.ResizeMethod != types.Crop && r.ThumbnailSize.ResizeMethod != types.Scale {
return &util.JSONResponse{
Code: http.StatusBadRequest,
- JSON: jsonerror.Unknown("method must be one of crop or scale"),
+ JSON: spec.Unknown("method must be one of crop or scale"),
}
}
}