MM-7881 non-case sensitive username notifications off by default (#13851)

Automatic Merge
Этот коммит содержится в:
Ths2-9Y-LqJt6
2020-03-25 09:43:25 -07:00
коммит произвёл GitHub
родитель 0340eb466f
Коммит c4701394d3
3 изменённых файлов: 9 добавлений и 9 удалений

Просмотреть файл

@@ -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))

Просмотреть файл

@@ -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, ",")
}

Просмотреть файл

@@ -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) {