Merge branch 'develop' into feat/v5-ui-redesign

This commit is contained in:
Sivin Varghese
2026-01-15 13:42:00 +05:30
committed by GitHub
4 changed files with 21 additions and 11 deletions
+5 -2
View File
@@ -159,8 +159,11 @@ class ActionCableListener < BaseListener
end
def contact_deleted(event)
contact, account = extract_contact_and_account(event)
broadcast(account, [account_token(account)], CONTACT_DELETED, contact.push_event_data)
contact_data = event.data[:contact_data]
account = Account.find_by(id: contact_data[:account_id])
return if account.blank?
broadcast(account, [account_token(account)], CONTACT_DELETED, contact_data)
end
def conversation_mentioned(event)
+10 -6
View File
@@ -179,11 +179,9 @@ class Contact < ApplicationRecord
end
def self.resolved_contacts(use_crm_v2: false)
if use_crm_v2
where(contact_type: 'lead')
else
where("contacts.email <> '' OR contacts.phone_number <> '' OR contacts.identifier <> ''")
end
return where(contact_type: 'lead') if use_crm_v2
where("contacts.email <> '' OR contacts.phone_number <> '' OR contacts.identifier <> ''")
end
def discard_invalid_attrs
@@ -243,7 +241,13 @@ class Contact < ApplicationRecord
end
def dispatch_destroy_event
Rails.configuration.dispatcher.dispatch(CONTACT_DELETED, Time.zone.now, contact: self)
# Pass serialized data instead of ActiveRecord object to avoid DeserializationError
# when the async EventDispatcherJob runs after the contact has been deleted
Rails.configuration.dispatcher.dispatch(
CONTACT_DELETED,
Time.zone.now,
contact_data: push_event_data.merge(account_id: account_id)
)
end
end
Contact.include_mod_with('Concerns::Contact')
@@ -20,7 +20,9 @@ class Whatsapp::TemplateProcessorService
def find_template
channel.message_templates.find do |t|
t['name'] == template_params['name'] && t['language'] == template_params['language'] && t['status']&.downcase == 'approved'
t['name'] == template_params['name'] &&
t['language']&.downcase == template_params['language']&.downcase &&
t['status']&.downcase == 'approved'
end
end
+3 -2
View File
@@ -117,13 +117,14 @@ describe ActionCableListener do
describe '#contact_deleted' do
let(:event_name) { :'contact.deleted' }
let!(:contact) { create(:contact, account: account) }
let!(:event) { Events::Base.new(event_name, Time.zone.now, contact: contact) }
let(:contact_data) { contact.push_event_data.merge(account_id: contact.account_id) }
let!(:event) { Events::Base.new(event_name, Time.zone.now, contact_data: contact_data) }
it 'sends message to account admins, inbox agents' do
expect(ActionCableBroadcastJob).to receive(:perform_later).with(
["account_#{account.id}"],
'contact.deleted',
contact.push_event_data.merge(account_id: account.id)
contact_data
)
listener.contact_deleted(event)
end