feat: Enable Capacity Config UI (#5164)
- Enables Capacity Config in UI - Rewrite auto assignment Logic to consider only online agents fixes: #4990
This commit is contained in:
26
app/models/concerns/auto_assignment_handler.rb
Normal file
26
app/models/concerns/auto_assignment_handler.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module AutoAssignmentHandler
|
||||
extend ActiveSupport::Concern
|
||||
include Events::Types
|
||||
|
||||
included do
|
||||
after_save :run_auto_assignment
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def run_auto_assignment
|
||||
# Round robin kicks in on conversation create & update
|
||||
# run it only when conversation status changes to open
|
||||
return unless conversation_status_changed_to_open?
|
||||
return unless should_run_auto_assignment?
|
||||
|
||||
::AutoAssignment::AgentAssignmentService.new(conversation: self, allowed_agent_ids: inbox.member_ids_with_assignment_capacity).perform
|
||||
end
|
||||
|
||||
def should_run_auto_assignment?
|
||||
return false unless inbox.enable_auto_assignment?
|
||||
|
||||
# run only if assignee is blank or doesn't have access to inbox
|
||||
assignee.blank? || inbox.members.exclude?(assignee)
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user