refactor: clarify conversation open paths

This commit is contained in:
Sojan Jose
2026-07-22 16:40:11 -07:00
parent bb37face88
commit af6389bdd8
@@ -80,7 +80,7 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
def toggle_status
# FIXME: move this logic into a service object
if pending_to_open_by_bot?
if bot_handoff?
@conversation.bot_handoff!
elsif params[:status].present?
set_conversation_status
@@ -88,10 +88,10 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
else
@status = @conversation.toggle_status
end
update_assignment_after_open if @conversation.open? && Current.user.is_a?(User)
handle_human_open if @conversation.open? && Current.user.is_a?(User)
end
def pending_to_open_by_bot?
def bot_handoff?
return false unless Current.user.is_a?(AgentBot)
@conversation.status == 'pending' && params[:status] == 'open'
@@ -179,7 +179,7 @@ class Api::V1::Accounts::ConversationsController < Api::V1::Accounts::BaseContro
@conversation.snoozed_until = parse_date_time(params[:snoozed_until].to_s) if params[:snoozed_until]
end
def update_assignment_after_open
def handle_human_open
@conversation.assignee_agent_bot = nil
@conversation.assignee = current_user if current_user.agent?
@conversation.save!