Files
leadchat/app/jobs/webhooks/twilio_events_job.rb
Muhsin Keloth b1893c7d96 fix: Support location messages in Twilio WhatsApp integration (#11830)
Fixes location messages not appearing in conversations when sent via
Twilio. Location messages were being filtered out due to empty body
content and missing parameter handling.

![CleanShot 2025-06-27 at 20 48
12](https://github.com/user-attachments/assets/b5a75796-6937-49bc-b689-7d04f4ea5d09)
2025-06-30 11:35:32 +05:30

18 lines
591 B
Ruby

class Webhooks::TwilioEventsJob < ApplicationJob
queue_as :low
def perform(params = {})
# Skip processing if Body parameter, MediaUrl0, or location data is not present
# This is to skip processing delivery events being delivered to this endpoint
return if params[:Body].blank? && params[:MediaUrl0].blank? && !valid_location_message?(params)
::Twilio::IncomingMessageService.new(params: params).perform
end
private
def valid_location_message?(params)
params[:MessageType] == 'location' && params[:Latitude].present? && params[:Longitude].present?
end
end