chatwoot/app/jobs/webhooks
Vishnu Narayanan d6af182f82
fix: Use contact_id instead of sender_id for Instagram message locks (#12841)
Previously, the lock key for Instagram used sender_id, which for echo
messages (outgoing) would be the account's own ID. This caused all
outgoing messages to compete for the same lock, creating a bottleneck
during bulk messaging.

The fix introduces contact_instagram_id method that correctly identifies
the contact's ID regardless of message direction:
- For echo messages (outgoing): uses recipient.id (the contact)
- For incoming messages: uses sender.id (the contact)

This ensures each conversation has a unique lock, allowing parallel
processing of webhooks while maintaining race condition protection
within individual conversations.

Fixes lock acquisition errors in Sidekiq when processing bulk Instagram
messages.

Fixes
https://linear.app/chatwoot/issue/CW-5931/p0-mutexapplicationjoblockacquisitionerror-failed-to-acquire-lock-for

## Type of change

- [x] Bug fix (non-breaking change which fixes an issue)
2025-11-12 16:56:52 +05:30
..
facebook_delivery_job.rb feat: Facebook delivery reports (#8136) 2023-11-20 12:22:45 +05:30
facebook_events_job.rb fix: mutex timeout and error handling (#8770) 2024-01-24 14:18:21 +04:00
instagram_events_job.rb fix: Use contact_id instead of sender_id for Instagram message locks (#12841) 2025-11-12 16:56:52 +05:30
line_events_job.rb feat: Line Channel (#2904) 2021-09-11 01:31:17 +05:30
sms_events_job.rb feat: Bandwidth sms channel delivery reports (#8198) 2023-10-27 14:07:15 -07:00
telegram_events_job.rb feat(channel): add support for Telegram Business bots (#10181) (#11663) 2025-06-16 20:35:23 -07:00
twilio_delivery_status_job.rb feat: discard Twilio events when Body parameter is not present (#11096) 2025-03-17 12:47:11 +05:30
twilio_events_job.rb fix: Support location messages in Twilio WhatsApp integration (#11830) 2025-06-30 11:35:32 +05:30
whatsapp_events_job.rb chore: Logger for non-existent WhatsApp channels (#11064) 2025-03-12 15:50:38 -07:00