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. 
This commit is contained in:
@@ -79,4 +79,25 @@ RSpec.describe Webhooks::TwilioEventsJob do
|
||||
described_class.perform_now(params_with_media)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when location message is present' do
|
||||
let(:params_with_location) do
|
||||
{
|
||||
From: 'whatsapp:+1234567890',
|
||||
To: 'whatsapp:+0987654321',
|
||||
MessageType: 'location',
|
||||
Latitude: '12.160894393921',
|
||||
Longitude: '75.265205383301',
|
||||
AccountSid: 'AC123',
|
||||
SmsSid: 'SM123'
|
||||
}
|
||||
end
|
||||
|
||||
it 'processes the location message' do
|
||||
service = double
|
||||
expect(Twilio::IncomingMessageService).to receive(:new).with(params: params_with_location).and_return(service)
|
||||
expect(service).to receive(:perform)
|
||||
described_class.perform_now(params_with_location)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -260,5 +260,27 @@ describe Twilio::IncomingMessageService do
|
||||
expect(conversation.reload.messages.last.attachments.map(&:file_type)).to contain_exactly('image', 'image')
|
||||
end
|
||||
end
|
||||
|
||||
context 'when a location message is received' do
|
||||
let(:params_with_location) do
|
||||
{
|
||||
SmsSid: 'SMxx',
|
||||
From: '+12345',
|
||||
AccountSid: 'ACxxx',
|
||||
MessagingServiceSid: twilio_channel.messaging_service_sid,
|
||||
MessageType: 'location',
|
||||
Latitude: '12.160894393921',
|
||||
Longitude: '75.265205383301'
|
||||
}
|
||||
end
|
||||
|
||||
it 'creates a message with location attachment' do
|
||||
described_class.new(params: params_with_location).perform
|
||||
|
||||
message = conversation.reload.messages.last
|
||||
expect(message.attachments.count).to eq(1)
|
||||
expect(message.attachments.first.file_type).to eq('location')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user