summaryrefslogtreecommitdiffstats
path: root/model/post.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-09-27 11:09:09 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2017-09-27 11:09:09 -0400
commit1bd66589a2adc67df5df9c108a2f2ecc77dfdf44 (patch)
treec01834361dbee38ede126afd0345b9512af885c0 /model/post.go
parent62e54a09e642d2af30dc55b66408bb36fae5bda5 (diff)
downloadchat-1bd66589a2adc67df5df9c108a2f2ecc77dfdf44.tar.gz
chat-1bd66589a2adc67df5df9c108a2f2ecc77dfdf44.tar.bz2
chat-1bd66589a2adc67df5df9c108a2f2ecc77dfdf44.zip
Allow custom post types (#7468)
Diffstat (limited to 'model/post.go')
-rw-r--r--model/post.go6
1 files changed, 4 insertions, 2 deletions
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)
}