iachat/app/services/whatsapp
Muhsin Keloth cd2c58726f
fix: Ensure message is always present in conversation_created webhook for WhatsApp attachment messages (#12507)
Fixes https://github.com/chatwoot/chatwoot/issues/11753 and
https://github.com/chatwoot/chatwoot/issues/12442

**Problem**
When a WhatsApp conversation started with a media message, the
conversation created webhook would sometimes fire before the message and
its relationships were fully committed to the database. This resulted in
the message being missing
from the webhook payload, breaking external automations that rely on
this field.

**Solution**

Added `ActiveRecord::Base.transaction` wrapper around the core message
processing operations in `Whatsapp::IncomingMessageBaseService` to
ensure atomic execution:

- `set_conversation` (creates conversation)
- `create_messages` (creates message with account_id)
- `clear_message_source_id_from_redis` (cleanup)

Now the webhook only triggers after all related data is fully persisted,
guaranteeing message availability.
2025-09-25 18:19:09 +05:30
..
phone_normalizers feat: Extract Brazil phone number normalization into generic service (#12492) 2025-09-25 11:23:43 +05:30
providers feat(whatsapp): add optional phone_number_id parameter to media retrieval API (#11823) 2025-09-23 09:16:59 +05:30
channel_creation_service.rb fix: setup webhook for create and update should be done after db commit (#12176) 2025-08-13 20:53:31 +05:30
embedded_signup_service.rb fix: setup webhook for create and update should be done after db commit (#12176) 2025-08-13 20:53:31 +05:30
facebook_api_client.rb feat: add support to embedded whatsapp coexistence method (#12108) 2025-08-08 18:28:50 +05:30
incoming_message_base_service.rb fix: Ensure message is always present in conversation_created webhook for WhatsApp attachment messages (#12507) 2025-09-25 18:19:09 +05:30
incoming_message_service_helpers.rb feat: Extract Brazil phone number normalization into generic service (#12492) 2025-09-25 11:23:43 +05:30
incoming_message_service.rb feat: Support for Whatsapp Cloud API (#4938) 2022-07-06 21:45:03 +02:00
incoming_message_whatsapp_cloud_service.rb feat(whatsapp): add optional phone_number_id parameter to media retrieval API (#11823) 2025-09-23 09:16:59 +05:30
oneoff_campaign_service.rb fix: Improve WhatsApp template message error handling (#12168) 2025-08-12 16:31:56 +05:30
phone_info_service.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
phone_number_normalization_service.rb feat: Extract Brazil phone number normalization into generic service (#12492) 2025-09-25 11:23:43 +05:30
populate_template_parameters_service.rb feat: Add media_name support for WhatsApp templates document files (#12462) 2025-09-18 15:25:31 +05:30
reauthorization_service.rb feat: add reauth flow for wa embedded signup (#11940) 2025-08-08 01:48:45 +05:30
send_on_whatsapp_service.rb fix: Improve WhatsApp template message error handling (#12168) 2025-08-12 16:31:56 +05:30
template_parameter_converter_service.rb fix: Handle nil processed_params for WhatsApp templates without params (#12177) 2025-08-12 22:56:53 +05:30
template_processor_service.rb feat: Add media_name support for WhatsApp templates document files (#12462) 2025-09-18 15:25:31 +05:30
token_exchange_service.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
token_validation_service.rb feat: Whatsapp embedded signup (#11612) 2025-07-14 21:37:06 -07:00
webhook_setup_service.rb feat: add support to embedded whatsapp coexistence method (#12108) 2025-08-08 18:28:50 +05:30
webhook_teardown_service.rb feat: Remove subscription on WhatsApp inbox delete (#11977) 2025-07-24 14:04:19 +04:00