diff options
Diffstat (limited to 'model/post.go')
-rw-r--r-- | model/post.go | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/model/post.go b/model/post.go index 5578514b5..2c90d8b7b 100644 --- a/model/post.go +++ b/model/post.go @@ -10,9 +10,10 @@ 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" ) type Post struct { @@ -112,6 +113,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 } @@ -155,3 +160,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 +} |