From c4701394d3f6ad2233f5ab0a44e90d8cca8a341a Mon Sep 17 00:00:00 2001 From: Ths2-9Y-LqJt6 Date: Wed, 25 Mar 2020 09:43:25 -0700 Subject: [PATCH] MM-7881 non-case sensitive username notifications off by default (#13851) Automatic Merge --- app/import_functions_test.go | 6 +++--- model/user.go | 4 ++-- model/user_test.go | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/import_functions_test.go b/app/import_functions_test.go index ef57c39b6b..b0c5717cf1 100644 --- a/app/import_functions_test.go +++ b/app/import_functions_test.go @@ -4,7 +4,6 @@ package app import ( - "fmt" "io/ioutil" "os" "path/filepath" @@ -1218,7 +1217,7 @@ func TestImportImportUser(t *testing.T) { checkNotifyProp(t, user, model.PUSH_STATUS_NOTIFY_PROP, model.STATUS_ONLINE) checkNotifyProp(t, user, model.CHANNEL_MENTIONS_NOTIFY_PROP, "true") checkNotifyProp(t, user, model.COMMENTS_NOTIFY_PROP, model.COMMENTS_NOTIFY_ROOT) - checkNotifyProp(t, user, model.MENTION_KEYS_NOTIFY_PROP, fmt.Sprintf("%s,@%s", username, username)) + checkNotifyProp(t, user, model.MENTION_KEYS_NOTIFY_PROP, "") // Set Notify Props with Mention keys data.NotifyProps = &UserNotifyPropsImportData{ @@ -1537,7 +1536,8 @@ func TestImportUserDefaultNotifyProps(t *testing.T) { Username: &username, Email: ptrStr(model.NewId() + "@example.com"), NotifyProps: &UserNotifyPropsImportData{ - Email: ptrStr("false"), + Email: ptrStr("false"), + MentionKeys: ptrStr(""), }, } require.Nil(t, th.App.importUser(&data, false)) diff --git a/model/user.go b/model/user.go index e9322acfbb..eed5e84093 100644 --- a/model/user.go +++ b/model/user.go @@ -391,7 +391,7 @@ func (u *User) SetDefaultNotifications() { u.NotifyProps[PUSH_NOTIFY_PROP] = USER_NOTIFY_MENTION u.NotifyProps[DESKTOP_NOTIFY_PROP] = USER_NOTIFY_MENTION u.NotifyProps[DESKTOP_SOUND_NOTIFY_PROP] = "true" - u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] = u.Username + ",@" + u.Username + u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] = "" u.NotifyProps[CHANNEL_MENTIONS_NOTIFY_PROP] = "true" u.NotifyProps[PUSH_STATUS_NOTIFY_PROP] = STATUS_AWAY u.NotifyProps[COMMENTS_NOTIFY_PROP] = COMMENTS_NOTIFY_NEVER @@ -406,7 +406,7 @@ func (u *User) UpdateMentionKeysFromUsername(oldUsername string) { } } - u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] = u.Username + ",@" + u.Username + u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] = "" if len(nonUsernameKeys) > 0 { u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] += "," + strings.Join(nonUsernameKeys, ",") } diff --git a/model/user_test.go b/model/user_test.go index d81d6e5492..3f8340cf65 100644 --- a/model/user_test.go +++ b/model/user_test.go @@ -75,19 +75,19 @@ func TestUserPreUpdate(t *testing.T) { func TestUserUpdateMentionKeysFromUsername(t *testing.T) { user := User{Username: "user"} user.SetDefaultNotifications() - assert.Equalf(t, user.NotifyProps["mention_keys"], "user,@user", "default mention keys are invalid: %v", user.NotifyProps["mention_keys"]) + assert.Equalf(t, user.NotifyProps["mention_keys"], "", "default mention keys are invalid: %v", user.NotifyProps["mention_keys"]) user.Username = "person" user.UpdateMentionKeysFromUsername("user") - assert.Equalf(t, user.NotifyProps["mention_keys"], "person,@person", "mention keys are invalid after changing username: %v", user.NotifyProps["mention_keys"]) + assert.Equalf(t, user.NotifyProps["mention_keys"], "", "mention keys are invalid after changing username: %v", user.NotifyProps["mention_keys"]) user.NotifyProps["mention_keys"] += ",mention" user.UpdateMentionKeysFromUsername("person") - assert.Equalf(t, user.NotifyProps["mention_keys"], "person,@person,mention", "mention keys are invalid after adding extra mention keyword: %v", user.NotifyProps["mention_keys"]) + assert.Equalf(t, user.NotifyProps["mention_keys"], ",mention", "mention keys are invalid after adding extra mention keyword: %v", user.NotifyProps["mention_keys"]) user.Username = "user" user.UpdateMentionKeysFromUsername("person") - assert.Equalf(t, user.NotifyProps["mention_keys"], "user,@user,mention", "mention keys are invalid after changing username with extra mention keyword: %v", user.NotifyProps["mention_keys"]) + assert.Equalf(t, user.NotifyProps["mention_keys"], ",mention", "mention keys are invalid after changing username with extra mention keyword: %v", user.NotifyProps["mention_keys"]) } func TestUserIsValid(t *testing.T) {