diff options
Diffstat (limited to 'model/post.go')
-rw-r--r-- | model/post.go | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/model/post.go b/model/post.go index 248d40321..5c86ce70d 100644 --- a/model/post.go +++ b/model/post.go @@ -10,9 +10,11 @@ import ( ) const ( - POST_DEFAULT = "" - POST_SLACK_ATTACHMENT = "slack_attachment" - POST_JOIN_LEAVE = "join_leave" + POST_SYSTEM_MESSAGE_PREFIX = "system_" + POST_DEFAULT = "" + POST_SLACK_ATTACHMENT = "slack_attachment" + POST_JOIN_LEAVE = "system_join_leave" + POST_HEADER_CHANGE = "system_header_change" ) type Post struct { @@ -26,7 +28,6 @@ type Post struct { ParentId string `json:"parent_id"` OriginalId string `json:"original_id"` Message string `json:"message"` - ImgCount int64 `json:"img_count"` Type string `json:"type"` Props StringInterface `json:"props"` Hashtags string `json:"hashtags"` @@ -105,7 +106,7 @@ func (o *Post) IsValid() *AppError { } // should be removed once more message types are supported - if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_SLACK_ATTACHMENT) { + if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_SLACK_ATTACHMENT || o.Type == POST_HEADER_CHANGE) { return NewAppError("Post.IsValid", "Invalid type", "id="+o.Type) } @@ -113,6 +114,10 @@ func (o *Post) IsValid() *AppError { return NewAppError("Post.IsValid", "Invalid filenames", "id="+o.Id) } + if utf8.RuneCountInString(StringInterfaceToJson(o.Props)) > 8000 { + return NewAppError("Post.IsValid", "Invalid props", "id="+o.Id) + } + return nil } @@ -156,3 +161,7 @@ func (o *Post) AddProp(key string, value interface{}) { func (o *Post) PreExport() { } + +func (o *Post) IsSystemMessage() bool { + return len(o.Type) >= len(POST_SYSTEM_MESSAGE_PREFIX) && o.Type[:len(POST_SYSTEM_MESSAGE_PREFIX)] == POST_SYSTEM_MESSAGE_PREFIX +} |