diff --git a/app/services/whatsapp/baileys_handlers/presence_update.rb b/app/services/whatsapp/baileys_handlers/presence_update.rb index 053969293..46e47bace 100644 --- a/app/services/whatsapp/baileys_handlers/presence_update.rb +++ b/app/services/whatsapp/baileys_handlers/presence_update.rb @@ -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 diff --git a/spec/services/csat_survey_service_spec.rb b/spec/services/csat_survey_service_spec.rb index eea91afb7..b46f47c87 100644 --- a/spec/services/csat_survey_service_spec.rb +++ b/spec/services/csat_survey_service_spec.rb @@ -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