[MM-41170] Disable bot accounts from getting notification emails (#19447)

Этот коммит содержится в:
Moises Sanchez
2022-03-05 07:10:25 -08:00
коммит произвёл GitHub
родитель 3be329b5e8
Коммит c114aba628
2 изменённых файлов: 18 добавлений и 0 удалений

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

@@ -646,6 +646,11 @@ func max(a, b int64) int64 {
}
func (a *App) userAllowsEmail(user *model.User, channelMemberNotificationProps model.StringMap, post *model.Post) bool {
// if user is a bot account, then we do not send email
if user.IsBot {
return false
}
userAllowsEmails := user.NotifyProps[model.EmailNotifyProp] != "false"
// if CRT is ON for user and the post is a reply disregard the channelEmail setting

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

@@ -2488,6 +2488,19 @@ func TestUserAllowsEmail(t *testing.T) {
assert.False(t, th.App.userAllowsEmail(user, channelMemberNotificationProps, &model.Post{Type: model.PostTypeAutoResponder}))
})
t.Run("should return false in the case user is a bot", func(t *testing.T) {
user := th.CreateUser()
th.App.ConvertUserToBot(user)
channelMemberNotifcationProps := model.StringMap{
model.EmailNotifyProp: model.ChannelNotifyDefault,
model.MarkUnreadNotifyProp: model.ChannelMarkUnreadAll,
}
assert.False(t, th.App.userAllowsEmail(user, channelMemberNotifcationProps, &model.Post{Type: model.PostTypeAutoResponder}))
})
}
func TestInsertGroupMentions(t *testing.T) {