fix: resolve CI failures from presence update method collision
Rename consolidate_contact to consolidate_presence_contact in PresenceUpdate to avoid overriding the 3-arg version from GroupContactMessageHandler when both modules are mixed into IncomingMessageBaileysService. Fix CSAT spec side effects where conversation callbacks triggered ActivityMessageJob unexpectedly during test setup.
This commit is contained in:
parent
104a05a511
commit
02f70ff611
@ -8,7 +8,7 @@ module Whatsapp::BaileysHandlers::PresenceUpdate
|
|||||||
return if data[:id].blank? || data[:id].include?('@g.us')
|
return if data[:id].blank? || data[:id].include?('@g.us')
|
||||||
|
|
||||||
lid, phone = extract_presence_identifiers(data)
|
lid, phone = extract_presence_identifiers(data)
|
||||||
consolidate_contact(lid, phone) if lid && phone
|
consolidate_presence_contact(lid, phone) if lid && phone
|
||||||
|
|
||||||
data[:presences]&.each_value do |presence_data|
|
data[:presences]&.each_value do |presence_data|
|
||||||
handle_presence(lid, phone, presence_data)
|
handle_presence(lid, phone, presence_data)
|
||||||
@ -50,7 +50,7 @@ module Whatsapp::BaileysHandlers::PresenceUpdate
|
|||||||
inbox.contact_inboxes.find_by(contact_id: contact.id)
|
inbox.contact_inboxes.find_by(contact_id: contact.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
def consolidate_contact(lid, phone)
|
def consolidate_presence_contact(lid, phone)
|
||||||
Whatsapp::ContactInboxConsolidationService.new(
|
Whatsapp::ContactInboxConsolidationService.new(
|
||||||
inbox: inbox, phone: phone, lid: lid, identifier: "#{lid}@lid"
|
inbox: inbox, phone: phone, lid: lid, identifier: "#{lid}@lid"
|
||||||
).perform
|
).perform
|
||||||
|
|||||||
@ -48,9 +48,10 @@ describe CsatSurveyService do
|
|||||||
|
|
||||||
context 'when CSAT survey should not be sent' do
|
context 'when CSAT survey should not be sent' do
|
||||||
it 'does nothing when conversation is not resolved' do
|
it 'does nothing when conversation is not resolved' do
|
||||||
conversation.update!(status: :open)
|
open_conversation = create(:conversation, contact_inbox: contact_inbox, inbox: inbox, account: account, status: :open)
|
||||||
|
open_service = described_class.new(conversation: open_conversation)
|
||||||
|
|
||||||
service.perform
|
open_service.perform
|
||||||
|
|
||||||
expect(MessageTemplates::Template::CsatSurvey).not_to have_received(:new)
|
expect(MessageTemplates::Template::CsatSurvey).not_to have_received(:new)
|
||||||
expect(Conversations::ActivityMessageJob).not_to have_received(:perform_later)
|
expect(Conversations::ActivityMessageJob).not_to have_received(:perform_later)
|
||||||
@ -66,7 +67,7 @@ describe CsatSurveyService do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it 'does nothing when CSAT already sent' do
|
it 'does nothing when CSAT already sent' do
|
||||||
create(:message, conversation: conversation, content_type: :input_csat)
|
create(:message, conversation: conversation, content_type: :input_csat, message_type: :outgoing)
|
||||||
|
|
||||||
service.perform
|
service.perform
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user