feat: Activity messages for team assignments (#1893)

- assignment messages when the conversation team is changed
- change assignee based on team
- move round-robin and assignee logic to concerns
This commit is contained in:
Sojan Jose
2021-03-12 15:13:58 +05:30
committed by GitHub
parent 38d1b0eae3
commit 42e83de5b0
9 changed files with 291 additions and 132 deletions

View File

@@ -0,0 +1,26 @@
module RoundRobinHandler
extend ActiveSupport::Concern
include Events::Types
included do
after_save :run_round_robin
end
private
def run_round_robin
# 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_round_robin?
::RoundRobin::AssignmentService.new(conversation: self).perform
end
def should_round_robin?
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