feat: Handle Facebook send message/attachments errors (#8197)

This commit is contained in:
Muhsin Keloth
2023-10-25 21:29:25 +05:30
committed by GitHub
parent 4fc62ed9ae
commit 58f47eb02c
2 changed files with 20 additions and 1 deletions

View File

@@ -87,6 +87,15 @@ describe Facebook::SendOnFacebookService do
tag: 'ACCOUNT_UPDATE'
}, { page_id: facebook_channel.page_id })
end
it 'if message sent from chatwoot is failed' do
message = create(:message, message_type: 'outgoing', inbox: facebook_inbox, account: account, conversation: conversation)
allow(bot).to receive(:deliver).and_return({ error: { message: 'Invalid OAuth access token.', type: 'OAuthException', code: 190,
fbtrace_id: 'BLBz/WZt8dN' } }.to_json)
described_class.new(message: message).perform
expect(bot).to have_received(:deliver)
expect(message.reload.status).to eq('failed')
end
end
end
end