mirror of
https://github.com/lingble/chatwoot.git
synced 2025-11-01 19:48:08 +00:00
fix: Warn Facebook error code 100-2018218 (#6632)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user