MM-29379 Ignore channel mentions when channel is muted and channel mention setting is not updated by the user (#15992)

Этот коммит содержится в:
sowmiyamuthuraman
2020-11-04 14:43:24 +05:30
коммит произвёл GitHub
родитель 66731e2740
Коммит 5a6d8387f5
2 изменённых файлов: 26 добавлений и 1 удалений

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

@@ -907,7 +907,8 @@ func addMentionKeywordsForUser(keywords map[string][]string, profile *model.User
// Add @channel and @all to keywords if user has them turned on and the server allows them
if allowChannelMentions {
ignoreChannelMentions := channelNotifyProps[model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP] == model.IGNORE_CHANNEL_MENTIONS_ON
// Ignore channel mentions if channel is muted and channel mention setting is default
ignoreChannelMentions := channelNotifyProps[model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP] == model.IGNORE_CHANNEL_MENTIONS_ON || (channelNotifyProps[model.MARK_UNREAD_NOTIFY_PROP] == model.USER_NOTIFY_MENTION && channelNotifyProps[model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP] == model.IGNORE_CHANNEL_MENTIONS_DEFAULT)
if profile.NotifyProps[model.CHANNEL_MENTIONS_NOTIFY_PROP] == "true" && !ignoreChannelMentions {
keywords["@channel"] = append(keywords["@channel"], profile.Id)

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

@@ -1548,6 +1548,30 @@ func TestAddMentionKeywordsForUser(t *testing.T) {
assert.NotContains(t, keywords["@here"], user.Id)
})
t.Run("should not add @channel/@all/@here when channel is muted and channel mention setting is not updated by user", func(t *testing.T) {
user := &model.User{
Id: model.NewId(),
Username: "user",
NotifyProps: map[string]string{
model.CHANNEL_MENTIONS_NOTIFY_PROP: "true",
},
}
channelNotifyProps := map[string]string{
model.MARK_UNREAD_NOTIFY_PROP: model.USER_NOTIFY_MENTION,
model.IGNORE_CHANNEL_MENTIONS_NOTIFY_PROP: model.IGNORE_CHANNEL_MENTIONS_DEFAULT,
}
status := &model.Status{
Status: model.STATUS_ONLINE,
}
keywords := map[string][]string{}
addMentionKeywordsForUser(keywords, user, channelNotifyProps, status, true)
assert.NotContains(t, keywords["@channel"], user.Id)
assert.NotContains(t, keywords["@all"], user.Id)
assert.NotContains(t, keywords["@here"], user.Id)
})
t.Run("should not add @here when when user is not online", func(t *testing.T) {
user := &model.User{
Id: model.NewId(),