From 1bd66589a2adc67df5df9c108a2f2ecc77dfdf44 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 27 Sep 2017 11:09:09 -0400 Subject: Allow custom post types (#7468) --- model/post.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'model/post.go') diff --git a/model/post.go b/model/post.go index d4fff7ef9..523a97c73 100644 --- a/model/post.go +++ b/model/post.go @@ -7,6 +7,7 @@ import ( "encoding/json" "io" "net/http" + "strings" "unicode/utf8" ) @@ -31,6 +32,7 @@ const ( POST_HASHTAGS_MAX_RUNES = 1000 POST_MESSAGE_MAX_RUNES = 4000 POST_PROPS_MAX_RUNES = 8000 + POST_CUSTOM_TYPE_PREFIX = "custom_" ) type Post struct { @@ -162,12 +164,12 @@ func (o *Post) IsValid() *AppError { 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 if !(o.Type == POST_DEFAULT || o.Type == POST_JOIN_LEAVE || o.Type == POST_ADD_REMOVE || o.Type == POST_JOIN_CHANNEL || o.Type == POST_LEAVE_CHANNEL || 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) { + o.Type == POST_DISPLAYNAME_CHANGE || o.Type == POST_CHANNEL_DELETED || + strings.HasPrefix(o.Type, POST_CUSTOM_TYPE_PREFIX)) { return NewAppError("Post.IsValid", "model.post.is_valid.type.app_error", nil, "id="+o.Type, http.StatusBadRequest) } -- cgit v1.2.3-1-g7c22