summaryrefslogtreecommitdiffstats
path: root/model/post.go
diff options
context:
space:
mode:
Diffstat (limited to 'model/post.go')
-rw-r--r--model/post.go8
1 files changed, 5 insertions, 3 deletions
diff --git a/model/post.go b/model/post.go
index 4a774b5d4..ae0627a03 100644
--- a/model/post.go
+++ b/model/post.go
@@ -40,7 +40,9 @@ const (
POST_FILEIDS_MAX_RUNES = 150
POST_FILENAMES_MAX_RUNES = 4000
POST_HASHTAGS_MAX_RUNES = 1000
- POST_MESSAGE_MAX_RUNES = 4000
+ POST_MESSAGE_MAX_RUNES_V1 = 4000
+ POST_MESSAGE_MAX_BYTES_V2 = 65535 // Maximum size of a TEXT column in MySQL
+ POST_MESSAGE_MAX_RUNES_V2 = POST_MESSAGE_MAX_BYTES_V2 / 4 // Assume a worst-case representation
POST_PROPS_MAX_RUNES = 8000
POST_PROPS_MAX_USER_RUNES = POST_PROPS_MAX_RUNES - 400 // Leave some room for system / pre-save modifications
POST_CUSTOM_TYPE_PREFIX = "custom_"
@@ -141,7 +143,7 @@ func (o *Post) Etag() string {
return Etag(o.Id, o.UpdateAt)
}
-func (o *Post) IsValid() *AppError {
+func (o *Post) IsValid(maxPostSize int) *AppError {
if len(o.Id) != 26 {
return NewAppError("Post.IsValid", "model.post.is_valid.id.app_error", nil, "", http.StatusBadRequest)
@@ -179,7 +181,7 @@ func (o *Post) IsValid() *AppError {
return NewAppError("Post.IsValid", "model.post.is_valid.original_id.app_error", nil, "", http.StatusBadRequest)
}
- if utf8.RuneCountInString(o.Message) > POST_MESSAGE_MAX_RUNES {
+ if utf8.RuneCountInString(o.Message) > maxPostSize {
return NewAppError("Post.IsValid", "model.post.is_valid.msg.app_error", nil, "id="+o.Id, http.StatusBadRequest)
}