diff options
author | =Corey Hulen <corey@hulen.com> | 2015-08-21 08:54:48 -0700 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-08-21 08:54:48 -0700 |
commit | 0ae7180ac5e0cea1e240a1d29c5822159762b2e3 (patch) | |
tree | 6fb954e8d5609286b861c3e378543f28180d84d5 /store | |
parent | 60be2a5636e52bd3193978691f9b53d896e4c45c (diff) | |
parent | ddcdcc3e2c85efbfd1d91d69c0f5c0af7c7cb1c7 (diff) | |
download | chat-0ae7180ac5e0cea1e240a1d29c5822159762b2e3.tar.gz chat-0ae7180ac5e0cea1e240a1d29c5822159762b2e3.tar.bz2 chat-0ae7180ac5e0cea1e240a1d29c5822159762b2e3.zip |
Merging
Diffstat (limited to 'store')
-rw-r--r-- | store/sql_user_store.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/store/sql_user_store.go b/store/sql_user_store.go index cd25b488b..4b1189c2e 100644 --- a/store/sql_user_store.go +++ b/store/sql_user_store.go @@ -5,6 +5,7 @@ package store import ( "fmt" + "strings" "github.com/mattermost/platform/model" "github.com/mattermost/platform/utils" ) @@ -163,6 +164,17 @@ func (us SqlUserStore) Update(user *model.User, allowActiveUpdate bool) StoreCha user.EmailVerified = false } + if user.Username != oldUser.Username { + nonUsernameKeys := []string{} + splitKeys := strings.Split(user.NotifyProps["mention_keys"], ",") + for _, key := range splitKeys { + if key != oldUser.Username && key != "@" + oldUser.Username { + nonUsernameKeys = append(nonUsernameKeys, key) + } + } + user.NotifyProps["mention_keys"] = strings.Join(nonUsernameKeys, ",") + user.Username + ",@" + user.Username + } + if count, err := us.GetMaster().Update(user); err != nil { if IsUniqueConstraintError(err.Error(), "Email", "users_email_teamid_key") { result.Err = model.NewAppError("SqlUserStore.Update", "This email is already taken. Please choose another", "user_id="+user.Id+", "+err.Error()) |