diff options
Diffstat (limited to 'model/file_info.go')
-rw-r--r-- | model/file_info.go | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/model/file_info.go b/model/file_info.go index 3071e6d4b..0ee2c50d8 100644 --- a/model/file_info.go +++ b/model/file_info.go @@ -10,6 +10,7 @@ import ( "image/gif" "io" "mime" + "net/http" "path/filepath" "strings" ) @@ -89,27 +90,27 @@ func (o *FileInfo) PreSave() { func (o *FileInfo) IsValid() *AppError { if len(o.Id) != 26 { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "") + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.id.app_error", nil, "", http.StatusBadRequest) } if len(o.CreatorId) != 26 { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id) + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.user_id.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if len(o.PostId) != 0 && len(o.PostId) != 26 { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id) + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.post_id.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if o.CreateAt == 0 { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id) + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if o.UpdateAt == 0 { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id) + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if o.Path == "" { - return NewLocAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id) + return NewAppError("FileInfo.IsValid", "model.file_info.is_valid.path.app_error", nil, "id="+o.Id, http.StatusBadRequest) } return nil @@ -147,7 +148,7 @@ func GetInfoForBytes(name string, data []byte) (*FileInfo, *AppError) { if gifConfig, err := gif.DecodeAll(bytes.NewReader(data)); err != nil { // Still return the rest of the info even though it doesn't appear to be an actual gif info.HasPreviewImage = true - err = NewLocAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name) + err = NewAppError("GetInfoForBytes", "model.file_info.get.gif.app_error", nil, "name="+name, http.StatusBadRequest) } else { info.HasPreviewImage = len(gifConfig.Image) == 1 } |