iachat/app
Gabriel Jablonski 521ce90e79
fix(whatsapp): consolidate fragmented phone/LID contacts to prevent lost messages (#241)
* fix(whatsapp): consolidate fragmented phone/LID contacts to prevent lost messages

When a WhatsApp user had two separate contacts (one by phone, one by LID)
with different contact_ids, the consolidation service did nothing. This caused
update_contact_info to crash with a phone_number uniqueness violation, silently
dropping incoming messages.

Now properly merges the two contacts by treating the phone contact as canonical,
moving conversations from the LID contact, and cleaning up duplicates.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): address CodeRabbit review feedback

- Destroy orphaned LID contact when it has no remaining contact_inboxes
- Clarify spec comment to past-tense (no longer an active bug)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* fix(whatsapp): route legacy-source contact_inbox into merge path

When a phone contact_inbox has a non-standard source_id (legacy format)
and a separate LID contact_inbox exists for a different contact,
the consolidation now merges them instead of early-returning.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

* test: assert orphaned LID contact is destroyed in legacy-source spec

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-19 19:20:11 -03:00
..
actions Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
assets feat: Hide installation identifier (#11722) 2025-06-17 15:45:40 -07:00
builders feat: add audio transcoding support for WhatsApp Cloud API (#220) 2026-02-22 16:21:50 -03:00
channels fix: Move contact events to account stream rather than individual user stream (#11082) 2025-03-13 17:46:48 -07:00
controllers feat: add custom HTML fields for portals (#233) 2026-03-09 11:47:41 -03:00
dashboards feat: Auto confirm user email when super admin make changes (#12418) 2025-09-23 20:14:02 +05:30
dispatchers feat: toggle typing status on channel provider (#39) 2025-05-03 00:39:39 -03:00
drops feat: Implement existing template linking for CSAT surveys (#218) 2026-02-18 18:00:29 -03:00
fields chore: improve plan-based feature handling with plan hierarchy (#11335) 2025-04-28 14:13:56 -07:00
finders feat: add SKIP_INCOMING_BCC_PROCESSING as internal config (#12484) 2025-09-22 17:52:56 +05:30
helpers Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
javascript feat: add kanban feature promotion with upgrade banner (#235) 2026-03-12 15:31:53 -03:00
jobs Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
listeners feat: mensagens agendadas (#198) 2026-01-30 22:08:16 -03:00
mailboxes Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
mailers fix: email delivery in Email::SendOnEmailService (#217) 2026-02-18 16:23:13 -03:00
models feat: add custom HTML fields for portals (#233) 2026-03-09 11:47:41 -03:00
policies Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
presenters fix(mailbox): handle malformed sender address headers (#13486) 2026-02-11 11:02:38 -08:00
services fix(whatsapp): consolidate fragmented phone/LID contacts to prevent lost messages (#241) 2026-03-19 19:20:11 -03:00
views feat: add custom HTML fields for portals (#233) 2026-03-09 11:47:41 -03:00