refactor(captain): simplify reopen engagement check in Enterprise::Message

The respond_to?(:captain_assistant) guard was redundant — the enterprise
message override and the inbox concern defining the association are loaded
under the same enterprise gate, so the association always exists here.
This commit is contained in:
Pranav
2026-07-14 16:30:14 -07:00
parent 94fe5318b4
commit cfcbe707e3
+5 -11
View File
@@ -15,22 +15,16 @@ module Enterprise::Message
private
# On reopen, a Captain inbox would normally re-pend the conversation for the bot. When the
# assistant won't engage (contact outside audience, or off-schedule), route to the human queue
# (open) instead of pending.
def reopen_resolved_conversation
return conversation.open! if captain_should_not_engage?
captain_assistant = conversation.inbox.captain_assistant
return super if captain_assistant.blank?
return conversation.open! unless captain_assistant.engages?(conversation.contact, conversation)
super
end
def captain_should_not_engage?
inbox = conversation.inbox
inbox.respond_to?(:captain_assistant) &&
inbox.captain_assistant.present? &&
!inbox.captain_assistant.engages?(conversation.contact, conversation)
end
def mark_pending_conversation_as_open_for_human_response
return unless captain_pending_conversation?
return unless human_response?