fix: Warn Facebook error code 100-2018218 (#6632)

This commit is contained in:
Tejaswini Chile
2023-03-09 13:51:10 +05:30
committed by GitHub
parent 757e1bb1f7
commit 54b7c98795
2 changed files with 24 additions and 1 deletions

View File

@@ -116,7 +116,11 @@ class Messages::Facebook::MessageBuilder < Messages::Messenger::MessageBuilder
result = {}
# OAuthException, code: 100, error_subcode: 2018218, message: (#100) No profile available for this user
# We don't need to capture this error as we don't care about contact params in case of echo messages
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception unless @outgoing_echo
if e.message.include?('2018218')
Rails.logger.warn e
else
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception unless @outgoing_echo
end
rescue StandardError => e
result = {}
ChatwootExceptionTracker.new(e, account: @inbox.account).capture_exception

View File

@@ -39,5 +39,24 @@ describe ::Messages::Facebook::MessageBuilder do
expect(facebook_channel.authorization_error_count).to eq(2)
end
it 'raises exception for non profile account' do
allow(Koala::Facebook::API).to receive(:new).and_return(fb_object)
allow(fb_object).to receive(:get_object).and_raise(Koala::Facebook::ClientError.new(400, '',
{
'type' => 'OAuthException',
'message' => '(#100) No profile available for this user.',
'error_subcode' => 2_018_218,
'code' => 100
}))
message_builder
contact = facebook_channel.inbox.contacts.first
# Refer: https://github.com/chatwoot/chatwoot/pull/3016 for this check
default_name = 'John Doe'
expect(facebook_channel.inbox.reload.contacts.count).to eq(1)
expect(contact.name).to eq(default_name)
end
end
end