[MM-41170] Disable bot accounts from getting notification emails (#19447)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
3be329b5e8
Коммит
c114aba628
@@ -646,6 +646,11 @@ func max(a, b int64) int64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (a *App) userAllowsEmail(user *model.User, channelMemberNotificationProps model.StringMap, post *model.Post) bool {
|
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"
|
userAllowsEmails := user.NotifyProps[model.EmailNotifyProp] != "false"
|
||||||
|
|
||||||
// if CRT is ON for user and the post is a reply disregard the channelEmail setting
|
// 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}))
|
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) {
|
func TestInsertGroupMentions(t *testing.T) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user