PLT-6262 Add config setting to disable file attachments (#6301)
* Add config setting to disable file attachments * Add unit tests * Updating UI for no attachments (#6312) * Update UI text on file upload System Console setting (#6313) * Update storage_settings.jsx * Update en.json
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
44a8f76d99
Коммит
49481caf6d
@@ -31,6 +31,11 @@ func InitFile() {
|
||||
}
|
||||
|
||||
func uploadFile(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
if !*utils.Cfg.FileSettings.EnableFileAttachments {
|
||||
c.Err = model.NewAppError("uploadFile", "api.file.attachments.disabled.app_error", nil, "", http.StatusNotImplemented)
|
||||
return
|
||||
}
|
||||
|
||||
if r.ContentLength > *utils.Cfg.FileSettings.MaxFileSize {
|
||||
c.Err = model.NewLocAppError("uploadFile", "api.file.upload_file.too_large.app_error", nil, "")
|
||||
c.Err.StatusCode = http.StatusRequestEntityTooLarge
|
||||
@@ -181,9 +186,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 {
|
||||
err := model.NewLocAppError("getFileInfoForRequest", "api.file.get_file_info_for_request.storage.app_error", nil, "")
|
||||
err.StatusCode = http.StatusNotImplemented
|
||||
return nil, err
|
||||
return nil, model.NewAppError("getFileInfoForRequest", "api.file.get_info_for_request.storage.app_error", nil, "", http.StatusNotImplemented)
|
||||
}
|
||||
|
||||
params := mux.Vars(r)
|
||||
|
||||
@@ -99,6 +99,18 @@ func TestUploadFile(t *testing.T) {
|
||||
t.Fatalf("file preview should've been saved in %v", expectedPreviewPath)
|
||||
}
|
||||
|
||||
enableFileAttachments := *utils.Cfg.FileSettings.EnableFileAttachments
|
||||
defer func() {
|
||||
*utils.Cfg.FileSettings.EnableFileAttachments = enableFileAttachments
|
||||
}()
|
||||
*utils.Cfg.FileSettings.EnableFileAttachments = false
|
||||
|
||||
if data, err := readTestFile("test.png"); err != nil {
|
||||
t.Fatal(err)
|
||||
} else if _, err = Client.UploadPostAttachment(data, channel.Id, "test.png"); err == nil {
|
||||
t.Fatal("should have errored")
|
||||
}
|
||||
|
||||
// Wait a bit for files to ready
|
||||
time.Sleep(2 * time.Second)
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user