fix: Check the file attachment URL exists before downloading attachments in Telegram. (#8679)
In rare cases, the API call to Telegram for the file path fails. We were logging the error in sentry, switching to logs instead. Co-authored-by: Sojan <sojan@pepalo.com>
This commit is contained in:
@@ -215,6 +215,26 @@ describe Telegram::IncomingMessageService do
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the API call to get the download path returns an error' do
|
||||
it 'does not process the attachment' do
|
||||
allow(telegram_channel.inbox.channel).to receive(:get_telegram_file_path).and_return(nil)
|
||||
params = {
|
||||
'update_id' => 2_342_342_343_242,
|
||||
'message' => {
|
||||
'document' => {
|
||||
'file_id' => 'AwADBAADbXXXXXXXXXXXGBdhD2l6_XX',
|
||||
'file_name' => 'Screenshot 2021-09-27 at 2.01.14 PM.png',
|
||||
'mime_type' => 'application/png',
|
||||
'file_size' => 536_392
|
||||
}
|
||||
}.merge(message_params)
|
||||
}.with_indifferent_access
|
||||
|
||||
described_class.new(inbox: telegram_channel.inbox, params: params).perform
|
||||
expect(telegram_channel.inbox.messages.first.attachments.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
context 'when valid location message params' do
|
||||
it 'creates appropriate conversations, message and contacts' do
|
||||
params = {
|
||||
|
||||
Reference in New Issue
Block a user