GH-13421 Autoresponder should not reply to bot DMs (#13583)
Этот коммит содержится в:
@@ -13,6 +13,10 @@ func (a *App) SendAutoResponseIfNecessary(channel *model.Channel, sender *model.
|
||||
return false, nil
|
||||
}
|
||||
|
||||
if sender.IsBot {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
receiverId := channel.GetOtherUserIdForDM(sender.Id)
|
||||
|
||||
receiver, err := a.GetUser(receiverId)
|
||||
|
||||
@@ -135,6 +135,39 @@ func TestSendAutoResponseIfNecessary(t *testing.T) {
|
||||
assert.Nil(t, err)
|
||||
assert.False(t, sent)
|
||||
})
|
||||
|
||||
t.Run("should not send auto response for bot", func(t *testing.T) {
|
||||
th := Setup(t).InitBasic()
|
||||
defer th.TearDown()
|
||||
|
||||
receiver := th.CreateUser()
|
||||
|
||||
patch := &model.UserPatch{
|
||||
NotifyProps: map[string]string{
|
||||
"auto_responder_active": "true",
|
||||
"auto_responder_message": "Hello, I'm unavailable today.",
|
||||
},
|
||||
}
|
||||
receiver, err := th.App.PatchUser(receiver.Id, patch, true)
|
||||
require.Nil(t, err)
|
||||
|
||||
channel := th.CreateDmChannel(receiver)
|
||||
|
||||
bot, err := th.App.CreateBot(&model.Bot{
|
||||
Username: "botusername",
|
||||
Description: "bot",
|
||||
OwnerId: th.BasicUser.Id,
|
||||
})
|
||||
assert.Nil(t, err)
|
||||
|
||||
botUser, err := th.App.GetUser(bot.UserId)
|
||||
assert.Nil(t, err)
|
||||
|
||||
sent, err := th.App.SendAutoResponseIfNecessary(channel, botUser)
|
||||
|
||||
assert.Nil(t, err)
|
||||
assert.False(t, sent)
|
||||
})
|
||||
}
|
||||
|
||||
func TestSendAutoResponseSuccess(t *testing.T) {
|
||||
|
||||
Ссылка в новой задаче
Block a user