Finally do away with NewLocAppError function. (#7498)

This cleans up the few NewLocAppError calls that crept in since the main
bulk of them were removed, and finally removes the NewLocAppError
function altogether.
Этот коммит содержится в:
George Goldberg
2017-09-25 13:25:43 +01:00
коммит произвёл Joram Wilander
родитель cff0c941f2
Коммит d6b5b681ae
5 изменённых файлов: 30 добавлений и 43 удалений

Просмотреть файл

@@ -309,8 +309,7 @@ func (a *App) DoUploadFile(now time.Time, teamId string, channelId string, userI
if info.IsImage() {
// Check dimensions before loading the whole thing into memory later on
if info.Width*info.Height > MaxImageSize {
err := model.NewLocAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]interface{}{"Filename": filename}, "")
err.StatusCode = http.StatusBadRequest
err := model.NewAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]interface{}{"Filename": filename}, "", http.StatusBadRequest)
return nil, err
}

Просмотреть файл

@@ -114,7 +114,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
!post.IsSystemMessage() &&
channel.Name == model.DEFAULT_CHANNEL &&
!CheckIfRolesGrantPermission(user.GetRoles(), model.PERMISSION_MANAGE_SYSTEM.Id) {
return nil, model.NewLocAppError("createPost", "api.post.create_post.town_square_read_only", nil, "")
return nil, model.NewAppError("createPost", "api.post.create_post.town_square_read_only", nil, "", http.StatusForbidden)
}
// Verify the parent/child relationships are correct

Просмотреть файл

@@ -522,7 +522,7 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
if utils.IsLicensed() && *utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly &&
channel.Name == model.DEFAULT_CHANNEL {
return model.NewLocAppError("HandleIncomingWebhook", "api.post.create_post.town_square_read_only", nil, "")
return model.NewAppError("HandleIncomingWebhook", "api.post.create_post.town_square_read_only", nil, "", http.StatusForbidden)
}
if channel.Type != model.CHANNEL_OPEN && !a.HasPermissionToChannel(hook.UserId, channel.Id, model.PERMISSION_READ_CHANNEL) {