diff options
author | George Goldberg <george@gberg.me> | 2017-09-15 13:32:11 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-09-15 08:32:11 -0400 |
commit | 2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d (patch) | |
tree | 513dee966bfa8d3810ddf631df90270acd342e4f /model/post.go | |
parent | 600beb5af3e35fd82a2b06995b67629d08fe0fe3 (diff) | |
download | chat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.tar.gz chat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.tar.bz2 chat-2be5577b88e5ff85a98b0a2b3e3a43b90cc99c6d.zip |
Model: NewLocAppError -> NewAppError (#7450)
Diffstat (limited to 'model/post.go')
-rw-r--r-- | model/post.go | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/model/post.go b/model/post.go index 1c2e9b937..2554c4f2e 100644 --- a/model/post.go +++ b/model/post.go @@ -6,6 +6,7 @@ package model import ( "encoding/json" "io" + "net/http" "unicode/utf8" ) @@ -118,47 +119,47 @@ func (o *Post) Etag() string { func (o *Post) IsValid() *AppError { if len(o.Id) != 26 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "", http.StatusBadRequest) } if o.CreateAt == 0 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.create_at.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.create_at.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if o.UpdateAt == 0 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.update_at.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.update_at.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if len(o.UserId) != 26 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.user_id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.user_id.app_error", nil, "", http.StatusBadRequest) } if len(o.ChannelId) != 26 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.channel_id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.channel_id.app_error", nil, "", http.StatusBadRequest) } if !(len(o.RootId) == 26 || len(o.RootId) == 0) { - return NewLocAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.root_id.app_error", nil, "", http.StatusBadRequest) } if !(len(o.ParentId) == 26 || len(o.ParentId) == 0) { - return NewLocAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.parent_id.app_error", nil, "", http.StatusBadRequest) } if len(o.ParentId) == 26 && len(o.RootId) == 0 { - return NewLocAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.root_parent.app_error", nil, "", http.StatusBadRequest) } if !(len(o.OriginalId) == 26 || len(o.OriginalId) == 0) { - return NewLocAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "") + return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest) } if utf8.RuneCountInString(o.Message) > POST_MESSAGE_MAX_RUNES { - return NewLocAppError("Post.IsValid", "model.post.is_valid.msg.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.msg.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if utf8.RuneCountInString(o.Hashtags) > POST_HASHTAGS_MAX_RUNES { - return NewLocAppError("Post.IsValid", "model.post.is_valid.hashtags.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.hashtags.app_error", nil, "id="+o.Id, http.StatusBadRequest) } // should be removed once more message types are supported @@ -167,19 +168,19 @@ func (o *Post) IsValid() *AppError { o.Type == POST_REMOVE_FROM_CHANNEL || o.Type == POST_ADD_TO_CHANNEL || o.Type == POST_SLACK_ATTACHMENT || o.Type == POST_HEADER_CHANGE || o.Type == POST_PURPOSE_CHANGE || o.Type == POST_DISPLAYNAME_CHANGE || o.Type == POST_CHANNEL_DELETED) { - return NewLocAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type) + return NewAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type, http.StatusBadRequest) } if utf8.RuneCountInString(ArrayToJson(o.Filenames)) > POST_FILENAMES_MAX_RUNES { - return NewLocAppError("Post.IsValid", "model.post.is_valid.filenames.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.filenames.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if utf8.RuneCountInString(ArrayToJson(o.FileIds)) > POST_FILEIDS_MAX_RUNES { - return NewLocAppError("Post.IsValid", "model.post.is_valid.file_ids.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.file_ids.app_error", nil, "id="+o.Id, http.StatusBadRequest) } if utf8.RuneCountInString(StringInterfaceToJson(o.Props)) > POST_PROPS_MAX_RUNES { - return NewLocAppError("Post.IsValid", "model.post.is_valid.props.app_error", nil, "id="+o.Id) + return NewAppError("Post.IsValid", "model.post.is_valid.props.app_error", nil, "id="+o.Id, http.StatusBadRequest) } return nil |