+
-
-
-
-
diff --git a/app/services/telegram/incoming_message_service.rb b/app/services/telegram/incoming_message_service.rb
index d18994a00..a36231634 100644
--- a/app/services/telegram/incoming_message_service.rb
+++ b/app/services/telegram/incoming_message_service.rb
@@ -130,6 +130,7 @@ class Telegram::IncomingMessageService
@message.attachments.new(
account_id: @message.account_id,
file_type: :location,
+ fallback_title: location_fallback_title,
coordinates_lat: location['latitude'],
coordinates_long: location['longitude']
)
@@ -139,6 +140,16 @@ class Telegram::IncomingMessageService
@file ||= visual_media_params || params[:message][:voice].presence || params[:message][:audio].presence || params[:message][:document].presence
end
+ def location_fallback_title
+ return '' if venue.blank?
+
+ venue[:title] || ''
+ end
+
+ def venue
+ @venue ||= params.dig(:message, :venue).presence
+ end
+
def location
@location ||= params.dig(:message, :location).presence
end
diff --git a/spec/services/telegram/incoming_message_service_spec.rb b/spec/services/telegram/incoming_message_service_spec.rb
index 795202894..3cade6343 100644
--- a/spec/services/telegram/incoming_message_service_spec.rb
+++ b/spec/services/telegram/incoming_message_service_spec.rb
@@ -255,6 +255,30 @@ describe Telegram::IncomingMessageService do
expect(Contact.all.first.name).to eq('Sojan Jose')
expect(telegram_channel.inbox.messages.first.attachments.first.file_type).to eq('location')
end
+
+ it 'creates appropriate conversations, message and contacts if venue is present' do
+ params = {
+ 'update_id' => 2_342_342_343_242,
+ 'message' => {
+ 'location': {
+ 'latitude': 37.7893768,
+ 'longitude': -122.3895553
+ },
+ venue: {
+ title: 'San Francisco'
+ }
+ }.merge(message_params)
+ }.with_indifferent_access
+ described_class.new(inbox: telegram_channel.inbox, params: params).perform
+ expect(telegram_channel.inbox.conversations.count).not_to eq(0)
+ expect(Contact.all.first.name).to eq('Sojan Jose')
+
+ attachment = telegram_channel.inbox.messages.first.attachments.first
+ expect(attachment.file_type).to eq('location')
+ expect(attachment.coordinates_lat).to eq(37.7893768)
+ expect(attachment.coordinates_long).to eq(-122.3895553)
+ expect(attachment.fallback_title).to eq('San Francisco')
+ end
end
context 'when valid callback_query params' do