Commit d6b5b681 authored by George Goldberg's avatar George Goldberg Committed by Joram Wilander

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.
parent cff0c941
...@@ -309,8 +309,7 @@ func (a *App) DoUploadFile(now time.Time, teamId string, channelId string, userI ...@@ -309,8 +309,7 @@ func (a *App) DoUploadFile(now time.Time, teamId string, channelId string, userI
if info.IsImage() { if info.IsImage() {
// Check dimensions before loading the whole thing into memory later on // Check dimensions before loading the whole thing into memory later on
if info.Width*info.Height > MaxImageSize { if info.Width*info.Height > MaxImageSize {
err := model.NewLocAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]interface{}{"Filename": filename}, "") err := model.NewAppError("uploadFile", "api.file.upload_file.large_image.app_error", map[string]interface{}{"Filename": filename}, "", http.StatusBadRequest)
err.StatusCode = http.StatusBadRequest
return nil, err return nil, err
} }
......
...@@ -114,7 +114,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo ...@@ -114,7 +114,7 @@ func (a *App) CreatePost(post *model.Post, channel *model.Channel, triggerWebhoo
!post.IsSystemMessage() && !post.IsSystemMessage() &&
channel.Name == model.DEFAULT_CHANNEL && channel.Name == model.DEFAULT_CHANNEL &&
!CheckIfRolesGrantPermission(user.GetRoles(), model.PERMISSION_MANAGE_SYSTEM.Id) { !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 // Verify the parent/child relationships are correct
......
...@@ -522,7 +522,7 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq ...@@ -522,7 +522,7 @@ func (a *App) HandleIncomingWebhook(hookId string, req *model.IncomingWebhookReq
if utils.IsLicensed() && *utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly && if utils.IsLicensed() && *utils.Cfg.TeamSettings.ExperimentalTownSquareIsReadOnly &&
channel.Name == model.DEFAULT_CHANNEL { 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) { if channel.Type != model.CHANNEL_OPEN && !a.HasPermissionToChannel(hook.UserId, channel.Id, model.PERMISSION_READ_CHANNEL) {
......
...@@ -108,18 +108,6 @@ func NewAppError(where string, id string, params map[string]interface{}, details ...@@ -108,18 +108,6 @@ func NewAppError(where string, id string, params map[string]interface{}, details
return ap return ap
} }
func NewLocAppError(where string, id string, params map[string]interface{}, details string) *AppError {
ap := &AppError{}
ap.Id = id
ap.params = params
ap.Message = id
ap.Where = where
ap.DetailedError = details
ap.StatusCode = 500
ap.IsOAuth = false
return ap
}
var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769") var encoding = base32.NewEncoding("ybndrfg8ejkmcpqxot1uwisza345h769")
// NewId is a globally unique identifier. It is a [A-Z0-9] string 26 // NewId is a globally unique identifier. It is a [A-Z0-9] string 26
......
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment