From 5e4e955e64827f96e379f1d4adb252556408e88e Mon Sep 17 00:00:00 2001 From: Sojan Jose Date: Thu, 26 Dec 2024 16:17:38 +0530 Subject: [PATCH] chore: Avoid contact inboxes getting deleted (#10612) We observed some rare instances on prod where a contact inbox was getting deleted during the contact merge action. the potential suspect is contact inbox objects already loaded into the memory getting cleared through the destroy association job. Reloading the object to avoid this case !!! --- app/actions/contact_merge_action.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/actions/contact_merge_action.rb b/app/actions/contact_merge_action.rb index 650dbe89f..2633c907d 100644 --- a/app/actions/contact_merge_action.rb +++ b/app/actions/contact_merge_action.rb @@ -54,7 +54,7 @@ class ContactMergeAction # attributes in base contact are given preference merged_attributes = mergee_contact_attributes.deep_merge(base_contact_attributes) - @mergee_contact.destroy! + @mergee_contact.reload.destroy! Rails.configuration.dispatcher.dispatch(CONTACT_MERGED, Time.zone.now, contact: @base_contact, tokens: [@base_contact.contact_inboxes.filter_map(&:pubsub_token)]) @base_contact.update!(merged_attributes)