MM-7881 non-case sensitive username notifications off by default (#13851)
Automatic Merge
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
0340eb466f
Коммит
c4701394d3
@@ -4,7 +4,6 @@
|
|||||||
package app
|
package app
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"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.PUSH_STATUS_NOTIFY_PROP, model.STATUS_ONLINE)
|
||||||
checkNotifyProp(t, user, model.CHANNEL_MENTIONS_NOTIFY_PROP, "true")
|
checkNotifyProp(t, user, model.CHANNEL_MENTIONS_NOTIFY_PROP, "true")
|
||||||
checkNotifyProp(t, user, model.COMMENTS_NOTIFY_PROP, model.COMMENTS_NOTIFY_ROOT)
|
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
|
// Set Notify Props with Mention keys
|
||||||
data.NotifyProps = &UserNotifyPropsImportData{
|
data.NotifyProps = &UserNotifyPropsImportData{
|
||||||
@@ -1537,7 +1536,8 @@ func TestImportUserDefaultNotifyProps(t *testing.T) {
|
|||||||
Username: &username,
|
Username: &username,
|
||||||
Email: ptrStr(model.NewId() + "@example.com"),
|
Email: ptrStr(model.NewId() + "@example.com"),
|
||||||
NotifyProps: &UserNotifyPropsImportData{
|
NotifyProps: &UserNotifyPropsImportData{
|
||||||
Email: ptrStr("false"),
|
Email: ptrStr("false"),
|
||||||
|
MentionKeys: ptrStr(""),
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
require.Nil(t, th.App.importUser(&data, false))
|
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[PUSH_NOTIFY_PROP] = USER_NOTIFY_MENTION
|
||||||
u.NotifyProps[DESKTOP_NOTIFY_PROP] = USER_NOTIFY_MENTION
|
u.NotifyProps[DESKTOP_NOTIFY_PROP] = USER_NOTIFY_MENTION
|
||||||
u.NotifyProps[DESKTOP_SOUND_NOTIFY_PROP] = "true"
|
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[CHANNEL_MENTIONS_NOTIFY_PROP] = "true"
|
||||||
u.NotifyProps[PUSH_STATUS_NOTIFY_PROP] = STATUS_AWAY
|
u.NotifyProps[PUSH_STATUS_NOTIFY_PROP] = STATUS_AWAY
|
||||||
u.NotifyProps[COMMENTS_NOTIFY_PROP] = COMMENTS_NOTIFY_NEVER
|
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 {
|
if len(nonUsernameKeys) > 0 {
|
||||||
u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] += "," + strings.Join(nonUsernameKeys, ",")
|
u.NotifyProps[MENTION_KEYS_NOTIFY_PROP] += "," + strings.Join(nonUsernameKeys, ",")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,19 +75,19 @@ func TestUserPreUpdate(t *testing.T) {
|
|||||||
func TestUserUpdateMentionKeysFromUsername(t *testing.T) {
|
func TestUserUpdateMentionKeysFromUsername(t *testing.T) {
|
||||||
user := User{Username: "user"}
|
user := User{Username: "user"}
|
||||||
user.SetDefaultNotifications()
|
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.Username = "person"
|
||||||
user.UpdateMentionKeysFromUsername("user")
|
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.NotifyProps["mention_keys"] += ",mention"
|
||||||
user.UpdateMentionKeysFromUsername("person")
|
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.Username = "user"
|
||||||
user.UpdateMentionKeysFromUsername("person")
|
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) {
|
func TestUserIsValid(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user