Fix: skip invalid access token from sentry (#6639)
This commit is contained in:
@@ -9,9 +9,8 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
|
||||
send_message_to_facebook fb_text_message_params if message.content.present?
|
||||
send_message_to_facebook fb_attachment_message_params if message.attachments.present?
|
||||
rescue Facebook::Messenger::FacebookError => e
|
||||
ChatwootExceptionTracker.new(e, account: message.account, user: message.sender).capture_exception
|
||||
# TODO : handle specific errors or else page will get disconnected
|
||||
# channel.authorization_error!
|
||||
handle_facebook_error(e)
|
||||
end
|
||||
|
||||
def send_message_to_facebook(delivery_params)
|
||||
@@ -67,4 +66,13 @@ class Facebook::SendOnFacebookService < Base::SendOnChannelService
|
||||
def last_incoming_message
|
||||
conversation.messages.incoming.last
|
||||
end
|
||||
|
||||
def handle_facebook_error(exception)
|
||||
# Refer: https://github.com/jgorset/facebook-messenger/blob/64fe1f5cef4c1e3fca295b205037f64dfebdbcab/lib/facebook/messenger/error.rb
|
||||
if exception.to_s.include?('The session has been invalidated') || exception.to_s.include?('Error validating access token')
|
||||
channel.authorization_error!
|
||||
else
|
||||
ChatwootExceptionTracker.new(exception, account: message.account, user: message.sender).capture_exception
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user