fix: Update the message status to failed if the outgoing Facebook message fails. (#8258)

This commit is contained in:
Muhsin Keloth
2023-11-01 06:10:17 +05:30
committed by GitHub
parent d876419b27
commit 68b8d721a7
2 changed files with 3 additions and 0 deletions

View File

@@ -11,6 +11,7 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
rescue Facebook::Messenger::FacebookError => e rescue Facebook::Messenger::FacebookError => e
# TODO : handle specific errors or else page will get disconnected # TODO : handle specific errors or else page will get disconnected
handle_facebook_error(e) handle_facebook_error(e)
message.update!(status: :failed, external_error: e.message)
end end
def send_message_to_facebook(delivery_params) def send_message_to_facebook(delivery_params)

View File

@@ -58,6 +58,8 @@ describe Facebook::SendOnFacebookService do
described_class.new(message: message).perform described_class.new(message: message).perform
expect(facebook_channel.authorization_error_count).to eq(1) expect(facebook_channel.authorization_error_count).to eq(1)
expect(message.reload.status).to eq('failed')
expect(message.reload.external_error).to eq('Error validating access token')
end end
it 'if message with attachment is sent from chatwoot and is outgoing' do it 'if message with attachment is sent from chatwoot and is outgoing' do