chore: Instagram reconnect fix (#3142)

This commit is contained in:
Sojan Jose 2021-10-06 16:23:32 +05:30 committed by GitHub
parent 271ca53c58
commit 219a8c4bc5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 6 deletions

View file

@ -15,7 +15,7 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
set_instagram_id(page_access_token, facebook_channel)
set_avatar(@facebook_inbox, page_id)
rescue StandardError => e
Rails.logger.info e
Sentry.capture_exception(e)
end
end
@ -55,8 +55,13 @@ class Api::V1::Accounts::CallbacksController < Api::V1::Accounts::BaseController
def update_fb_page(fb_page_id, access_token)
fb_page = get_fb_page(fb_page_id)
ActiveRecord::Base.transaction do
fb_page&.update!(user_access_token: @user_access_token, page_access_token: access_token)
set_instagram_id(access_token, fb_page)
fb_page&.reauthorized!
rescue StandardError => e
Sentry.capture_exception(e)
end
end
def get_fb_page(fb_page_id)

View file

@ -9,8 +9,9 @@ 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
Rails.logger.info e
channel.authorization_error!
Sentry.capture_exception(e)
# TODO : handle specific errors or else page will get disconnected
# channel.authorization_error!
end
def send_message_to_facebook(delivery_params)

View file

@ -18,7 +18,8 @@ class Instagram::SendOnInstagramService < Base::SendOnChannelService
send_to_facebook_page message_params
rescue StandardError => e
Sentry.capture_exception(e)
channel.authorization_error!
# TODO : handle specific errors or else page will get disconnected
# channel.authorization_error!
end
def message_params