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:
gabrieljablonski 2026-04-13 13:41:58 -03:00
parent 104a05a511
commit 02f70ff611
2 changed files with 6 additions and 5 deletions

View File

@ -8,7 +8,7 @@ module Whatsapp::BaileysHandlers::PresenceUpdate
return if data[:id].blank? || data[:id].include?('@g.us')
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|
handle_presence(lid, phone, presence_data)
@ -50,7 +50,7 @@ module Whatsapp::BaileysHandlers::PresenceUpdate
inbox.contact_inboxes.find_by(contact_id: contact.id)
end
def consolidate_contact(lid, phone)
def consolidate_presence_contact(lid, phone)
Whatsapp::ContactInboxConsolidationService.new(
inbox: inbox, phone: phone, lid: lid, identifier: "#{lid}@lid"
).perform

View File

@ -48,9 +48,10 @@ describe CsatSurveyService do
context 'when CSAT survey should not be sent' 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(Conversations::ActivityMessageJob).not_to have_received(:perform_later)
@ -66,7 +67,7 @@ describe CsatSurveyService do
end
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