Added support for Telegram Business bots. Telegram webhooks from such bots include the business_message field, which we transform into a standard message for Chatwoot. This PR also modifies how we handle replies, attachments, and image uploads when working with Telegram Business bots. demo: https://drive.google.com/file/d/1Yz82wXBVRtb-mxjXogkUju4hlJbt3qyh/view?usp=sharing&t=4 Fixes #10181
This commit is contained in:
@@ -40,6 +40,22 @@ RSpec.describe Telegram::SendAttachmentsService do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when this is business chat' do
|
||||
before { allow(channel).to receive(:business_connection_id).and_return('eooW3KF5WB5HxTD7T826') }
|
||||
|
||||
it 'sends all types of attachments in seperate groups and returns the last successful message ID from the batch' do
|
||||
attach_files(message)
|
||||
service.perform
|
||||
expect(a_request(:post, "#{telegram_api_url}/sendMediaGroup")
|
||||
.with { |req| req.body =~ /business_connection_id.+eooW3KF5WB5HxTD7T826/m })
|
||||
.to have_been_made.times(2)
|
||||
|
||||
expect(a_request(:post, "#{telegram_api_url}/sendDocument")
|
||||
.with { |req| req.body =~ /business_connection_id.+eooW3KF5WB5HxTD7T826/m })
|
||||
.to have_been_made.once
|
||||
end
|
||||
end
|
||||
|
||||
context 'when all attachments are photo and video' do
|
||||
before do
|
||||
2.times { attach_file_to_message(message, 'image', 'sample.png', 'image/png') }
|
||||
|
||||
Reference in New Issue
Block a user