summaryrefslogtreecommitdiffstats
path: root/api4/file.go
diff options
context:
space:
mode:
Diffstat (limited to 'api4/file.go')
-rw-r--r--api4/file.go21
1 files changed, 7 insertions, 14 deletions
diff --git a/api4/file.go b/api4/file.go
index 7dc13dafc..ab71b998b 100644
--- a/api4/file.go
+++ b/api4/file.go
@@ -160,8 +160,7 @@ func getFileThumbnail(c *Context, w http.ResponseWriter, r *http.Request) {
}
if info.ThumbnailPath == "" {
- c.Err = model.NewLocAppError("getFileThumbnail", "api.file.get_file_thumbnail.no_thumbnail.app_error", nil, "file_id="+info.Id)
- c.Err.StatusCode = http.StatusBadRequest
+ c.Err = model.NewAppError("getFileThumbnail", "api.file.get_file_thumbnail.no_thumbnail.app_error", nil, "file_id="+info.Id, http.StatusBadRequest)
return
}
@@ -181,8 +180,7 @@ func getFileLink(c *Context, w http.ResponseWriter, r *http.Request) {
}
if !utils.Cfg.FileSettings.EnablePublicLink {
- c.Err = model.NewLocAppError("getPublicLink", "api.file.get_public_link.disabled.app_error", nil, "")
- c.Err.StatusCode = http.StatusNotImplemented
+ c.Err = model.NewAppError("getPublicLink", "api.file.get_public_link.disabled.app_error", nil, "", http.StatusNotImplemented)
return
}
@@ -198,8 +196,7 @@ func getFileLink(c *Context, w http.ResponseWriter, r *http.Request) {
}
if len(info.PostId) == 0 {
- c.Err = model.NewLocAppError("getPublicLink", "api.file.get_public_link.no_post.app_error", nil, "file_id="+info.Id)
- c.Err.StatusCode = http.StatusBadRequest
+ c.Err = model.NewAppError("getPublicLink", "api.file.get_public_link.no_post.app_error", nil, "file_id="+info.Id, http.StatusBadRequest)
return
}
@@ -232,8 +229,7 @@ func getFilePreview(c *Context, w http.ResponseWriter, r *http.Request) {
}
if info.PreviewPath == "" {
- c.Err = model.NewLocAppError("getFilePreview", "api.file.get_file_preview.no_preview.app_error", nil, "file_id="+info.Id)
- c.Err.StatusCode = http.StatusBadRequest
+ c.Err = model.NewAppError("getFilePreview", "api.file.get_file_preview.no_preview.app_error", nil, "file_id="+info.Id, http.StatusBadRequest)
return
}
@@ -274,8 +270,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
}
if !utils.Cfg.FileSettings.EnablePublicLink {
- c.Err = model.NewLocAppError("getPublicFile", "api.file.get_public_link.disabled.app_error", nil, "")
- c.Err.StatusCode = http.StatusNotImplemented
+ c.Err = model.NewAppError("getPublicFile", "api.file.get_public_link.disabled.app_error", nil, "", http.StatusNotImplemented)
return
}
@@ -288,14 +283,12 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) {
hash := r.URL.Query().Get("h")
if len(hash) == 0 {
- c.Err = model.NewLocAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "")
- c.Err.StatusCode = http.StatusBadRequest
+ c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest)
return
}
if hash != app.GeneratePublicLinkHash(info.Id, *utils.Cfg.FileSettings.PublicLinkSalt) {
- c.Err = model.NewLocAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "")
- c.Err.StatusCode = http.StatusBadRequest
+ c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest)
return
}