Made further changes based on feedback
Этот коммит содержится в:
@@ -10,8 +10,6 @@ import (
|
||||
|
||||
const (
|
||||
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 {
|
||||
@@ -46,12 +44,11 @@ func (o *Preference) IsValid() *AppError {
|
||||
return NewAppError("Preference.IsValid", "Invalid user id", "user_id="+o.UserId)
|
||||
}
|
||||
|
||||
if len(o.Category) == 0 || len(o.Category) > 32 || !IsPreferenceCategoryValid(o.Category) {
|
||||
if len(o.Category) == 0 || len(o.Category) > 32 {
|
||||
return NewAppError("Preference.IsValid", "Invalid category", "category="+o.Category)
|
||||
}
|
||||
|
||||
// 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)) {
|
||||
if len(o.Name) == 0 || len(o.Name) > 32 {
|
||||
return NewAppError("Preference.IsValid", "Invalid name", "name="+o.Name)
|
||||
}
|
||||
|
||||
@@ -61,11 +58,3 @@ func (o *Preference) IsValid() *AppError {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func IsPreferenceCategoryValid(category string) bool {
|
||||
return category == PREFERENCE_CATEGORY_DIRECT_CHANNEL_SHOW || category == PREFERENCE_CATEGORY_TEST
|
||||
}
|
||||
|
||||
func IsPreferenceNameValid(name string) bool {
|
||||
return name == PREFERENCE_NAME_TEST
|
||||
}
|
||||
|
||||
Ссылка в новой задаче
Block a user