fix: Handle PermissionDeniedError for Dialogflow processor (#8252)
This commit is contained in:
@@ -7,6 +7,13 @@ class AdministratorNotifications::ChannelNotificationsMailer < ApplicationMailer
|
||||
send_mail_with_liquid(to: admin_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
def dialogflow_disconnect
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
subject = 'Your Dialogflow integration was disconnected'
|
||||
send_mail_with_liquid(to: admin_emails, subject: subject) and return
|
||||
end
|
||||
|
||||
def facebook_disconnect(inbox)
|
||||
return unless smtp_config_set_or_development?
|
||||
|
||||
|
||||
@@ -39,15 +39,25 @@ module Reauthorizable
|
||||
def prompt_reauthorization!
|
||||
::Redis::Alfred.set(reauthorization_required_key, true)
|
||||
|
||||
mailer = AdministratorNotifications::ChannelNotificationsMailer.with(account: account)
|
||||
|
||||
case self.class.name
|
||||
when 'Integrations::Hook'
|
||||
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).slack_disconnect.deliver_later if slack?
|
||||
process_integration_hook_reauthorization_emails(mailer)
|
||||
when 'Channel::FacebookPage'
|
||||
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).facebook_disconnect(inbox).deliver_later
|
||||
mailer.facebook_disconnect(inbox).deliver_later
|
||||
when 'Channel::Whatsapp'
|
||||
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).whatsapp_disconnect(inbox).deliver_later
|
||||
mailer.whatsapp_disconnect(inbox).deliver_later
|
||||
when 'Channel::Email'
|
||||
AdministratorNotifications::ChannelNotificationsMailer.with(account: account).email_disconnect(inbox).deliver_later
|
||||
mailer.email_disconnect(inbox).deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
def process_integration_hook_reauthorization_emails(mailer)
|
||||
if slack?
|
||||
mailer.slack_disconnect.deliver_later
|
||||
elsif dialogflow?
|
||||
mailer.dialogflow_disconnect.deliver_later
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -129,7 +129,7 @@ class Inbox < ApplicationRecord
|
||||
end
|
||||
|
||||
def active_bot?
|
||||
agent_bot_inbox&.active? || hooks.pluck(:app_id).include?('dialogflow')
|
||||
agent_bot_inbox&.active? || hooks.where(app_id: 'dialogflow', status: 'enabled').count.positive?
|
||||
end
|
||||
|
||||
def inbox_type
|
||||
|
||||
@@ -43,6 +43,10 @@ class Integrations::Hook < ApplicationRecord
|
||||
app_id == 'slack'
|
||||
end
|
||||
|
||||
def dialogflow?
|
||||
app_id == 'dialogflow'
|
||||
end
|
||||
|
||||
def disable
|
||||
update(status: 'disabled')
|
||||
end
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
<p>Hello there,</p>
|
||||
|
||||
<p>Your Dialogflow integration was disconnected because of permission issues. To resolve this, please delete the integration from the admin dashboard and reconnect it using new credentials.</p>
|
||||
Reference in New Issue
Block a user