diff options
author | Asaad Mahmood <asaad@spinpunch.com> | 2016-01-20 10:38:13 +0500 |
---|---|---|
committer | Asaad Mahmood <asaad@spinpunch.com> | 2016-01-20 10:38:13 +0500 |
commit | 547ad113c171ba9d2e3d7fc536b3184440b52303 (patch) | |
tree | c7afbb4684d63516e68b47b4a2a8fd8c52d813b2 /model | |
parent | 2b69cf31aea40d12690e97ce3981e3bd955f501b (diff) | |
parent | 1acd38b7b19521d06d274c42c00ce7072cd92196 (diff) | |
download | chat-547ad113c171ba9d2e3d7fc536b3184440b52303.tar.gz chat-547ad113c171ba9d2e3d7fc536b3184440b52303.tar.bz2 chat-547ad113c171ba9d2e3d7fc536b3184440b52303.zip |
Merge branch 'master' of https://github.com/mattermost/platform into ui-improvements
Diffstat (limited to 'model')
-rw-r--r-- | model/user.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/model/user.go b/model/user.go index 4ba35c6c4..7744b0073 100644 --- a/model/user.go +++ b/model/user.go @@ -6,11 +6,12 @@ package model import ( "encoding/json" "fmt" - "golang.org/x/crypto/bcrypt" "io" "regexp" "strings" "unicode/utf8" + + "golang.org/x/crypto/bcrypt" ) const ( @@ -24,6 +25,7 @@ const ( USER_NOTIFY_ALL = "all" USER_NOTIFY_MENTION = "mention" USER_NOTIFY_NONE = "none" + DEFAULT_LOCALE = "en" ) type User struct { @@ -51,6 +53,7 @@ type User struct { LastPasswordUpdate int64 `json:"last_password_update,omitempty"` LastPictureUpdate int64 `json:"last_picture_update,omitempty"` FailedAttempts int `json:"failed_attempts,omitempty"` + Locale string `json:"locale"` } // IsValid validates the user and returns an error if it isn't configured @@ -130,12 +133,17 @@ func (u *User) PreSave() { u.Username = strings.ToLower(u.Username) u.Email = strings.ToLower(u.Email) + u.Locale = strings.ToLower(u.Locale) u.CreateAt = GetMillis() u.UpdateAt = u.CreateAt u.LastPasswordUpdate = u.CreateAt + if u.Locale == "" { + u.Locale = DEFAULT_LOCALE + } + if u.Props == nil { u.Props = make(map[string]string) } @@ -153,6 +161,7 @@ func (u *User) PreSave() { func (u *User) PreUpdate() { u.Username = strings.ToLower(u.Username) u.Email = strings.ToLower(u.Email) + u.Locale = strings.ToLower(u.Locale) u.UpdateAt = GetMillis() if u.NotifyProps == nil || len(u.NotifyProps) == 0 { |