diff --git a/app/auto_responder.go b/app/auto_responder.go index 49b2d843fb..eba4c3cf28 100644 --- a/app/auto_responder.go +++ b/app/auto_responder.go @@ -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) diff --git a/app/auto_responder_test.go b/app/auto_responder_test.go index dcca57964e..860cee63f2 100644 --- a/app/auto_responder_test.go +++ b/app/auto_responder_test.go @@ -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) {