summaryrefslogtreecommitdiffstats
path: root/model/preference.go
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2015-10-13 11:52:17 -0400
committerhmhealey <harrisonmhealey@gmail.com>2015-10-13 12:29:31 -0400
commit2a39e8dbfab8506b09d0d030f87cac4c079b975a (patch)
treedd2ca36ca7ef73a2cf8eda11d6a62848d7d29a79 /model/preference.go
parent5cecf1afcd1d8e561a5b2d840e5bd1b588a74a27 (diff)
downloadchat-2a39e8dbfab8506b09d0d030f87cac4c079b975a.tar.gz
chat-2a39e8dbfab8506b09d0d030f87cac4c079b975a.tar.bz2
chat-2a39e8dbfab8506b09d0d030f87cac4c079b975a.zip
Removed Preference.AltId
Diffstat (limited to 'model/preference.go')
-rw-r--r--model/preference.go19
1 files changed, 7 insertions, 12 deletions
diff --git a/model/preference.go b/model/preference.go
index 434f55f40..187dbe848 100644
--- a/model/preference.go
+++ b/model/preference.go
@@ -9,17 +9,15 @@ import (
)
const (
- PREFERENCE_CATEGORY_DIRECT_CHANNELS = "direct_channels"
- PREFERENCE_CATEGORY_TEST = "test" // do not use, just for testing uniqueness while there's only one real category
- PREFERENCE_NAME_SHOW = "show"
- PREFERENCE_NAME_TEST = "test" // do not use, just for testing uniqueness while there's only one real name
+ PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW = "direct_channel_show"
+ PREFERENCE_CATEGORY_TEST = "test" // do not use, just for testing uniqueness while there's only one real category
+ PREFERENCE_NAME_TEST = "test" // do not use, just for testing while there's no constant name
)
type Preference struct {
UserId string `json:"user_id"`
Category string `json:"category"`
Name string `json:"name"`
- AltId string `json:"alt_id"`
Value string `json:"value"`
}
@@ -52,14 +50,11 @@ func (o *Preference) IsValid() *AppError {
return NewAppError("Preference.IsValid", "Invalid category", "category="+o.Category)
}
- if len(o.Name) == 0 || len(o.Name) > 32 || !IsPreferenceNameValid(o.Name) {
+ // name can either be a valid constant or an id
+ if len(o.Name) == 0 || len(o.Name) > 32 || !(len(o.Name) == 26 || IsPreferenceNameValid(o.Name)) {
return NewAppError("Preference.IsValid", "Invalid name", "name="+o.Name)
}
- if o.AltId != "" && len(o.AltId) != 26 {
- return NewAppError("Preference.IsValid", "Invalid alternate id", "altId="+o.AltId)
- }
-
if len(o.Value) > 128 {
return NewAppError("Preference.IsValid", "Value is too long", "value="+o.Value)
}
@@ -68,9 +63,9 @@ func (o *Preference) IsValid() *AppError {
}
func IsPreferenceCategoryValid(category string) bool {
- return category == PREFERENCE_CATEGORY_DIRECT_CHANNELS || category == PREFERENCE_CATEGORY_TEST
+ return category == PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW || category == PREFERENCE_CATEGORY_TEST
}
func IsPreferenceNameValid(name string) bool {
- return name == PREFERENCE_NAME_SHOW || name == PREFERENCE_NAME_TEST
+ return name == PREFERENCE_NAME_TEST
}