diff options
author | Chris <ccbrown112@gmail.com> | 2017-10-18 15:36:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-18 15:36:43 -0700 |
commit | 8e19ba029f889519d93cf272960dce858971106c (patch) | |
tree | d8f38ac62661fb8578e2b5c3c619fe31ab29f480 /api/file.go | |
parent | 34a87fa8f47b1447b73e3ae56866b654801b3eee (diff) | |
download | chat-8e19ba029f889519d93cf272960dce858971106c.tar.gz chat-8e19ba029f889519d93cf272960dce858971106c.tar.bz2 chat-8e19ba029f889519d93cf272960dce858971106c.zip |
Reduce utils.Cfg references (#7650)
* app.UpdateConfig method
* test fix
* another test fix
* the config override option as-was is just error prone, remove it for now
* derp
Diffstat (limited to 'api/file.go')
-rw-r--r-- | api/file.go | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/api/file.go b/api/file.go index 28007f222..bcb79bd5c 100644 --- a/api/file.go +++ b/api/file.go @@ -46,17 +46,17 @@ func (api *API) InitFile() { } func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) { - if !*utils.Cfg.FileSettings.EnableFileAttachments { + if !*c.App.Config().FileSettings.EnableFileAttachments { c.Err = model.NewAppError("uploadFile", "api.file.attachments.disabled.app_error", nil, "", http.StatusNotImplemented) return } - if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize { + if r.ContentLength > *c.App.Config().FileSettings.MaxFileSize { c.Err = model.NewAppError("uploadFile", "api.file.upload_file.too_large.app_error", nil, "", http.StatusRequestEntityTooLarge) return } - if err := r.ParseMultipartForm(*utils.Cfg.FileSettings.MaxFileSize); err != nil { + if err := r.ParseMultipartForm(*c.App.Config().FileSettings.MaxFileSize); err != nil { http.Error(w, err.Error(), http.StatusInternalServerError) return } @@ -159,7 +159,7 @@ func getFileInfo(c *Context, w http.ResponseWriter, r *http.Request) { } func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) { - if !utils.Cfg.FileSettings.EnablePublicLink { + if !c.App.Config().FileSettings.EnablePublicLink { c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_disabled.app_error", nil, "", http.StatusNotImplemented) return } @@ -173,7 +173,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) { hash := r.URL.Query().Get("h") if len(hash) > 0 { - correctHash := app.GeneratePublicLinkHash(info.Id, *utils.Cfg.FileSettings.PublicLinkSalt) + correctHash := app.GeneratePublicLinkHash(info.Id, *c.App.Config().FileSettings.PublicLinkSalt) if hash != correctHash { c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest) @@ -196,7 +196,7 @@ func getPublicFile(c *Context, w http.ResponseWriter, r *http.Request) { } func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool) (*model.FileInfo, *model.AppError) { - if len(*utils.Cfg.FileSettings.DriverName) == 0 { + if len(*c.App.Config().FileSettings.DriverName) == 0 { return nil, model.NewAppError("getFileInfoForRequest", "api.file.get_info_for_request.storage.app_error", nil, "", http.StatusNotImplemented) } @@ -231,10 +231,10 @@ func getFileInfoForRequest(c *Context, r *http.Request, requireFileVisible bool) } func getPublicFileOld(c *Context, w http.ResponseWriter, r *http.Request) { - if len(*utils.Cfg.FileSettings.DriverName) == 0 { + if len(*c.App.Config().FileSettings.DriverName) == 0 { c.Err = model.NewAppError("getPublicFile", "api.file.get_public_file_old.storage.app_error", nil, "", http.StatusNotImplemented) return - } else if !utils.Cfg.FileSettings.EnablePublicLink { + } else if !c.App.Config().FileSettings.EnablePublicLink { c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_disabled.app_error", nil, "", http.StatusNotImplemented) return } @@ -249,7 +249,7 @@ func getPublicFileOld(c *Context, w http.ResponseWriter, r *http.Request) { hash := r.URL.Query().Get("h") if len(hash) > 0 { - correctHash := app.GeneratePublicLinkHash(filename, *utils.Cfg.FileSettings.PublicLinkSalt) + correctHash := app.GeneratePublicLinkHash(filename, *c.App.Config().FileSettings.PublicLinkSalt) if hash != correctHash { c.Err = model.NewAppError("getPublicFile", "api.file.get_file.public_invalid.app_error", nil, "", http.StatusBadRequest) @@ -316,7 +316,7 @@ func writeFileResponse(filename string, contentType string, bytes []byte, w http } func getPublicLink(c *Context, w http.ResponseWriter, r *http.Request) { - if !utils.Cfg.FileSettings.EnablePublicLink { + if !c.App.Config().FileSettings.EnablePublicLink { c.Err = model.NewAppError("getPublicLink", "api.file.get_public_link.disabled.app_error", nil, "", http.StatusNotImplemented) return } |