PLT-8350 "mention" when channel user count equals to max allowed num (#7976)
Этот коммит содержится в:
@@ -935,7 +935,7 @@ func (a *App) GetMentionKeywordsInChannel(profiles map[string]*model.User, lookF
|
||||
|
||||
// Add @channel and @all to keywords if user has them turned on
|
||||
if lookForSpecialMentions {
|
||||
if int64(len(profiles)) < *a.Config().TeamSettings.MaxNotificationsPerChannel && profile.NotifyProps["channel"] == "true" {
|
||||
if int64(len(profiles)) <= *a.Config().TeamSettings.MaxNotificationsPerChannel && profile.NotifyProps["channel"] == "true" {
|
||||
keywords["@channel"] = append(keywords["@channel"], profile.Id)
|
||||
keywords["@all"] = append(keywords["@all"], profile.Id)
|
||||
|
||||
|
||||
@@ -544,7 +544,8 @@ func TestGetMentionKeywords(t *testing.T) {
|
||||
return duplicate_frequency
|
||||
}
|
||||
|
||||
// multiple users
|
||||
// multiple users but no more than MaxNotificationsPerChannel
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxNotificationsPerChannel = 4 })
|
||||
profiles = map[string]*model.User{
|
||||
user1.Id: user1,
|
||||
user2.Id: user2,
|
||||
@@ -568,6 +569,19 @@ func TestGetMentionKeywords(t *testing.T) {
|
||||
t.Fatal("should've mentioned user3 and user4 with @all")
|
||||
}
|
||||
|
||||
// multiple users and more than MaxNotificationsPerChannel
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.TeamSettings.MaxNotificationsPerChannel = 3 })
|
||||
mentions = th.App.GetMentionKeywordsInChannel(profiles, true)
|
||||
if len(mentions) != 4 {
|
||||
t.Fatal("should've returned four mention keywords")
|
||||
} else if _, ok := mentions["@channel"]; ok {
|
||||
t.Fatal("should not have mentioned any user with @channel")
|
||||
} else if _, ok := mentions["@all"]; ok {
|
||||
t.Fatal("should not have mentioned any user with @all")
|
||||
} else if _, ok := mentions["@here"]; ok {
|
||||
t.Fatal("should not have mentioned any user with @here")
|
||||
}
|
||||
|
||||
// no special mentions
|
||||
profiles = map[string]*model.User{
|
||||
user1.Id: user1,
|
||||
|
||||
Ссылка в новой задаче
Block a user