fix: Render missing captions for telegram media attachments (#3257)
This commit is contained in:
@@ -13,7 +13,7 @@ class Telegram::IncomingMessageService
|
|||||||
update_contact_avatar
|
update_contact_avatar
|
||||||
set_conversation
|
set_conversation
|
||||||
@message = @conversation.messages.create(
|
@message = @conversation.messages.create(
|
||||||
content: params[:message][:text],
|
content: params[:message][:text].presence || params[:message][:caption],
|
||||||
account_id: @inbox.account_id,
|
account_id: @inbox.account_id,
|
||||||
inbox_id: @inbox.id,
|
inbox_id: @inbox.id,
|
||||||
message_type: :incoming,
|
message_type: :incoming,
|
||||||
|
|||||||
@@ -24,6 +24,26 @@ describe Telegram::IncomingMessageService do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context 'when valid caption params' do
|
||||||
|
it 'creates appropriate conversations, message and contacts' do
|
||||||
|
params = {
|
||||||
|
'update_id' => 2_342_342_343_242,
|
||||||
|
'message' => {
|
||||||
|
'message_id' => 1,
|
||||||
|
'from' => {
|
||||||
|
'id' => 23, 'is_bot' => false, 'first_name' => 'Sojan', 'last_name' => 'Jose', 'username' => 'sojan', 'language_code' => 'en'
|
||||||
|
},
|
||||||
|
'chat' => { 'id' => 23, 'first_name' => 'Sojan', 'last_name' => 'Jose', 'username' => 'sojan', 'type' => 'private' },
|
||||||
|
'date' => 1_631_132_077, 'caption' => 'test'
|
||||||
|
}
|
||||||
|
}.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')
|
||||||
|
expect(telegram_channel.inbox.messages.first.content).to eq('test')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
context 'when group messages' do
|
context 'when group messages' do
|
||||||
it 'doesnot create conversations, message and contacts' do
|
it 'doesnot create conversations, message and contacts' do
|
||||||
params = {
|
params = {
|
||||||
|
|||||||
Reference in New Issue
Block a user