diff --git a/app/listeners/agent_bot_listener.rb b/app/listeners/agent_bot_listener.rb index 016a9cfc3..9a5748b84 100644 --- a/app/listeners/agent_bot_listener.rb +++ b/app/listeners/agent_bot_listener.rb @@ -15,7 +15,7 @@ class AgentBotListener < BaseListener agent_bots_for(inbox, conversation).each { |agent_bot| process_webhook_bot_event(agent_bot, payload) } end - def assignee_changed(event) + def conversation_updated(event) conversation = extract_conversation_and_account(event)[0] return if conversation.assignee_agent_bot.blank? diff --git a/app/models/concerns/assignment_handler.rb b/app/models/concerns/assignment_handler.rb index ec7c62ec1..a9f529f65 100644 --- a/app/models/concerns/assignment_handler.rb +++ b/app/models/concerns/assignment_handler.rb @@ -29,7 +29,7 @@ module AssignmentHandler def notify_assignment_change { - ASSIGNEE_CHANGED => -> { saved_change_to_assignee_id? || saved_change_to_assignee_agent_bot_id? }, + ASSIGNEE_CHANGED => -> { saved_change_to_assignee_id? }, TEAM_CHANGED => -> { saved_change_to_team_id? } }.each do |event, condition| condition.call && dispatcher_dispatch(event, previous_changes) diff --git a/spec/listeners/agent_bot_listener_spec.rb b/spec/listeners/agent_bot_listener_spec.rb index 66732bcf8..d3a0ba59b 100644 --- a/spec/listeners/agent_bot_listener_spec.rb +++ b/spec/listeners/agent_bot_listener_spec.rb @@ -57,8 +57,8 @@ describe AgentBotListener do end end - describe '#assignee_changed' do - let(:event_name) { 'assignee.changed' } + describe '#conversation_updated' do + let(:event_name) { 'conversation.updated' } let!(:event) { Events::Base.new(event_name, Time.zone.now, conversation: conversation) } context 'when conversation is assigned to an agent bot' do @@ -68,15 +68,15 @@ describe AgentBotListener do it 'sends webhook to the assigned agent bot' do expect(AgentBots::WebhookJob).to receive(:perform_later).with(agent_bot.outgoing_url, - conversation.webhook_data.merge(event: 'assignee_changed')).once - listener.assignee_changed(event) + conversation.webhook_data.merge(event: 'conversation_updated')).once + listener.conversation_updated(event) end end context 'when conversation is not assigned to an agent bot' do it 'does not send webhook' do expect(AgentBots::WebhookJob).not_to receive(:perform_later) - listener.assignee_changed(event) + listener.conversation_updated(event) end end end