summaryrefslogtreecommitdiffstats
path: root/model/channel.go
diff options
context:
space:
mode:
authorChristopher Speller <crspeller@gmail.com>2016-11-04 17:20:21 -0400
committerHarrison Healey <harrisonmhealey@gmail.com>2016-11-04 17:20:21 -0400
commit18745b2d5c1899bc279696548cb3ebecf7c6b90f (patch)
tree23cf9a3f8a75a89970792dd6ce0ff5b26df82850 /model/channel.go
parent20254073cb9976e783875f997a291829e6a0d78d (diff)
downloadchat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.tar.gz
chat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.tar.bz2
chat-18745b2d5c1899bc279696548cb3ebecf7c6b90f.zip
Increase Channel Purpose length to 250, and add channel field length handling code to the slack importer (#4458)
* Increase Channel Purpose length to 250. This commit increases the maxmimum length of the channel purpose field to 250, including the database migration necessary. It also adds a method to the Slack importer to check the lengths of channel properties before importing, and truncate them if necessary. Fixes #4168 * Fix database migration.
Diffstat (limited to 'model/channel.go')
-rw-r--r--model/channel.go20
1 files changed, 12 insertions, 8 deletions
diff --git a/model/channel.go b/model/channel.go
index 7dee079c5..2ad257ccc 100644
--- a/model/channel.go
+++ b/model/channel.go
@@ -10,10 +10,14 @@ import (
)
const (
- CHANNEL_OPEN = "O"
- CHANNEL_PRIVATE = "P"
- CHANNEL_DIRECT = "D"
- DEFAULT_CHANNEL = "town-square"
+ CHANNEL_OPEN = "O"
+ CHANNEL_PRIVATE = "P"
+ CHANNEL_DIRECT = "D"
+ DEFAULT_CHANNEL = "town-square"
+ CHANNEL_DISPLAY_NAME_MAX_RUNES = 64
+ CHANNEL_NAME_MAX_LENGTH = 64
+ CHANNEL_HEADER_MAX_RUNES = 1024
+ CHANNEL_PURPOSE_MAX_RUNES = 250
)
type Channel struct {
@@ -75,11 +79,11 @@ func (o *Channel) IsValid() *AppError {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.update_at.app_error", nil, "id="+o.Id)
}
- if utf8.RuneCountInString(o.DisplayName) > 64 {
+ if utf8.RuneCountInString(o.DisplayName) > CHANNEL_DISPLAY_NAME_MAX_RUNES {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.display_name.app_error", nil, "id="+o.Id)
}
- if len(o.Name) > 64 {
+ if len(o.Name) > CHANNEL_NAME_MAX_LENGTH {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.name.app_error", nil, "id="+o.Id)
}
@@ -91,11 +95,11 @@ func (o *Channel) IsValid() *AppError {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.type.app_error", nil, "id="+o.Id)
}
- if utf8.RuneCountInString(o.Header) > 1024 {
+ if utf8.RuneCountInString(o.Header) > CHANNEL_HEADER_MAX_RUNES {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.header.app_error", nil, "id="+o.Id)
}
- if utf8.RuneCountInString(o.Purpose) > 128 {
+ if utf8.RuneCountInString(o.Purpose) > CHANNEL_PURPOSE_MAX_RUNES {
return NewLocAppError("Channel.IsValid", "model.channel.is_valid.purpose.app_error", nil, "id="+o.Id)
}