chore: Auto resolution job for captain (#9898)

- Add a conversation auto-resolution job for the captain integration
This commit is contained in:
Sojan Jose
2024-08-06 16:15:11 -07:00
committed by GitHub
parent 91b713f6f5
commit cb4ad28a13
4 changed files with 58 additions and 11 deletions

View File

@@ -1,4 +1,4 @@
class ResponseBot::InboxPendingConversationsResolutionJob < ApplicationJob
class Captain::InboxPendingConversationsResolutionJob < ApplicationJob
queue_as :low
def perform(inbox)

View File

@@ -1,9 +1,32 @@
module Enterprise::Account::ConversationsResolutionSchedulerJob
def perform
super
# TODO: remove this when response bot is remove in favor of captain
resolve_response_bot_conversations
# This is responsible for resolving captain conversations
resolve_captain_conversations
end
private
def resolve_response_bot_conversations
# This is responsible for resolving response bot conversations
Account.feature_response_bot.all.find_each(batch_size: 100) do |account|
account.inboxes.each do |inbox|
ResponseBot::InboxPendingConversationsResolutionJob.perform_later(inbox) if inbox.response_bot_enabled?
Captain::InboxPendingConversationsResolutionJob.perform_later(inbox) if inbox.response_bot_enabled?
end
end
end
def resolve_captain_conversations
Integrations::Hook.where(app_id: 'captain').all.find_each(batch_size: 100) do |hook|
next unless hook.enabled?
inboxes = Inbox.where(id: hook.settings['inbox_ids'].split(','))
inboxes.each do |inbox|
Captain::InboxPendingConversationsResolutionJob.perform_later(inbox)
end
end
end