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

This commit is contained in:
Moises Sanchez
2022-03-05 16:10:25 +01:00
committed by GitHub
parent 3be329b5e8
commit c114aba628
2 changed files with 18 additions and 0 deletions
+5
View File
@@ -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
+13
View File
@@ -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) {