iachat/spec/services/whatsapp
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
..
baileys_handlers fix(whatsapp): consolidate fragmented phone/LID contacts to prevent lost messages (#241) 2026-03-19 19:20:11 -03:00
providers fix: normalize audio/opus content type to audio/ogg for WhatsApp attachments (#223) 2026-02-24 22:01:18 -03:00
zapi_handlers test: update outgoing message spec to reflect nil sender from WhatsApp 2026-02-01 14:48:59 -03:00
channel_creation_service_spec.rb Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
contact_inbox_consolidation_service_spec.rb fix(whatsapp): consolidate fragmented phone/LID contacts to prevent lost messages (#241) 2026-03-19 19:20:11 -03:00
csat_template_service_spec.rb feat: Implement existing template linking for CSAT surveys (#218) 2026-02-18 18:00:29 -03:00
embedded_signup_service_spec.rb feat: Add WhatsApp health monitoring and self-service registration completion (#12556) 2025-10-02 11:25:48 +05:30
facebook_api_client_spec.rb fix: Subscribe app to WABA before overriding webhook callback URL (#13279) 2026-02-02 16:50:35 +05:30
incoming_message_baileys_service_spec.rb fix: resolve race condition on slow networks by re-checking message source_id after acquiring contact lock (#210) 2026-02-05 15:33:10 -03:00
incoming_message_service_spec.rb Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
incoming_message_whatsapp_cloud_service_spec.rb feat: implement event dispatching for incoming WhatsApp messages (#230) 2026-02-28 12:06:24 -03:00
incoming_message_zapi_service_spec.rb feat(zapi): handle contact messages and ignore notifications (#124) 2025-10-26 10:48:06 -03:00
message_dedup_lock_spec.rb fix: duplicate message_created webhooks for WhatsApp messages (#13523) 2026-02-17 14:01:10 +05:30
oneoff_campaign_service_spec.rb Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
phone_info_service_spec.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
populate_template_parameters_service_spec.rb fix: Normalize URLs with spaces in WhatsApp template parameters (#12594) 2025-10-08 15:33:06 +05:30
send_on_whatsapp_service_spec.rb Merge branch 'main' into chore/merge-upstream-4.11.0 2026-02-17 23:05:26 -03:00
template_parameter_converter_service_spec.rb fix: Handle nil processed_params for WhatsApp templates without params (#12177) 2025-08-12 22:56:53 +05:30
token_exchange_service_spec.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
token_validation_service_spec.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
webhook_setup_service_spec.rb fix: Setup webhooks for manual WhatsApp Cloud channel creation (#13278) 2026-01-19 14:12:36 +04:00
webhook_teardown_service_spec.rb feat: add reauth flow for wa embedded signup (#11940) 2025-08-08 01:48:45 +05:30