fix: prevent deserialization error on deletion (#13264)

This commit is contained in:
Tanmay Deep Sharma
2026-01-14 18:00:12 +05:30
committed by GitHub
parent 4e0b091ef8
commit ee7187d2ed
3 changed files with 18 additions and 10 deletions

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')