Skip to content

Commit

Permalink
fix: Update the message status to failed if the outgoing Facebook m…
Browse files Browse the repository at this point in the history
…essage fails. (#8258)
  • Loading branch information
muhsin-k committed Nov 1, 2023
1 parent d876419 commit 68b8d72
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/services/facebook/send_on_facebook_service.rb
Expand Up @@ -11,6 +11,7 @@ def perform_reply
rescue Facebook::Messenger::FacebookError => e
# TODO : handle specific errors or else page will get disconnected
handle_facebook_error(e)
message.update!(status: :failed, external_error: e.message)
end

def send_message_to_facebook(delivery_params)
Expand Down
2 changes: 2 additions & 0 deletions spec/services/facebook/send_on_facebook_service_spec.rb
Expand Up @@ -58,6 +58,8 @@
described_class.new(message: message).perform

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

it 'if message with attachment is sent from chatwoot and is outgoing' do
Expand Down

0 comments on commit 68b8d72

Please sign in to comment.