App: NewLocAppError -> NewAppError (#7327)
* App: NewLocAppError -> NewAppError * Remove statuscode that got missed.
Этот коммит содержится в:
коммит произвёл
Harrison Healey
родитель
d9ec7d9240
Коммит
e85b5fb988
14
app/post.go
14
app/post.go
@@ -24,16 +24,14 @@ func CreatePostAsUser(post *model.Post) (*model.Post, *model.AppError) {
|
||||
// Check that channel has not been deleted
|
||||
var channel *model.Channel
|
||||
if result := <-Srv.Store.Channel().Get(post.ChannelId, true); result.Err != nil {
|
||||
err := model.NewLocAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, result.Err.Error())
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
err := model.NewAppError("CreatePostAsUser", "api.context.invalid_param.app_error", map[string]interface{}{"Name": "post.channel_id"}, result.Err.Error(), http.StatusBadRequest)
|
||||
return nil, err
|
||||
} else {
|
||||
channel = result.Data.(*model.Channel)
|
||||
}
|
||||
|
||||
if channel.DeleteAt != 0 {
|
||||
err := model.NewLocAppError("createPost", "api.post.create_post.can_not_post_to_deleted.error", nil, "")
|
||||
err.StatusCode = http.StatusBadRequest
|
||||
err := model.NewAppError("createPost", "api.post.create_post.can_not_post_to_deleted.error", nil, "", http.StatusBadRequest)
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -124,11 +122,11 @@ func CreatePost(post *model.Post, channel *model.Channel, triggerWebhooks bool)
|
||||
var parentPostList *model.PostList
|
||||
if pchan != nil {
|
||||
if presult := <-pchan; presult.Err != nil {
|
||||
return nil, model.NewLocAppError("createPost", "api.post.create_post.root_id.app_error", nil, "")
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.root_id.app_error", nil, "", http.StatusBadRequest)
|
||||
} else {
|
||||
parentPostList = presult.Data.(*model.PostList)
|
||||
if len(parentPostList.Posts) == 0 || !parentPostList.IsChannelId(post.ChannelId) {
|
||||
return nil, model.NewLocAppError("createPost", "api.post.create_post.channel_root_id.app_error", nil, "")
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.channel_root_id.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
if post.ParentId == "" {
|
||||
@@ -138,7 +136,7 @@ func CreatePost(post *model.Post, channel *model.Channel, triggerWebhooks bool)
|
||||
if post.RootId != post.ParentId {
|
||||
parent := parentPostList.Posts[post.ParentId]
|
||||
if parent == nil {
|
||||
return nil, model.NewLocAppError("createPost", "api.post.create_post.parent_id.app_error", nil, "")
|
||||
return nil, model.NewAppError("createPost", "api.post.create_post.parent_id.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -442,7 +440,7 @@ func GetPermalinkPost(postId string, userId string) (*model.PostList, *model.App
|
||||
list := result.Data.(*model.PostList)
|
||||
|
||||
if len(list.Order) != 1 {
|
||||
return nil, model.NewLocAppError("getPermalinkTmp", "api.post_get_post_by_id.get.app_error", nil, "")
|
||||
return nil, model.NewAppError("getPermalinkTmp", "api.post_get_post_by_id.get.app_error", nil, "", http.StatusNotFound)
|
||||
}
|
||||
post := list.Posts[list.Order[0]]
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user