feat (ee): APIs to configure an auto assignment limit for inboxes (#4672)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
This commit is contained in:
@@ -20,7 +20,6 @@ class Account < ApplicationRecord
|
||||
include FlagShihTzu
|
||||
include Reportable
|
||||
include Featurable
|
||||
prepend_mod_with('Account')
|
||||
|
||||
DEFAULT_QUERY_SETTING = {
|
||||
flag_query_mode: :bit_operator,
|
||||
@@ -146,3 +145,5 @@ class Account < ApplicationRecord
|
||||
ActiveRecord::Base.connection.exec_query("drop sequence IF EXISTS conv_dpid_seq_#{id}")
|
||||
end
|
||||
end
|
||||
|
||||
Account.prepend_mod_with('Account')
|
||||
|
||||
@@ -14,7 +14,7 @@ module RoundRobinHandler
|
||||
return unless conversation_status_changed_to_open?
|
||||
return unless should_round_robin?
|
||||
|
||||
::RoundRobin::AssignmentService.new(conversation: self).perform
|
||||
::RoundRobin::AssignmentService.new(conversation: self, allowed_member_ids: inbox.member_ids_with_assignment_capacity).perform
|
||||
end
|
||||
|
||||
def should_round_robin?
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#
|
||||
# id :integer not null, primary key
|
||||
# allow_messages_after_resolved :boolean default(TRUE)
|
||||
# auto_assignment_config :jsonb
|
||||
# channel_type :string
|
||||
# csat_survey_enabled :boolean default(FALSE)
|
||||
# email_address :string
|
||||
@@ -35,6 +36,7 @@ class Inbox < ApplicationRecord
|
||||
validates :name, presence: true
|
||||
validates :account_id, presence: true
|
||||
validates :timezone, inclusion: { in: TZInfo::Timezone.all_identifiers }
|
||||
validate :ensure_valid_max_assignment_limit
|
||||
|
||||
belongs_to :account
|
||||
|
||||
@@ -118,9 +120,19 @@ class Inbox < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
def member_ids_with_assignment_capacity
|
||||
members.ids
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def ensure_valid_max_assignment_limit
|
||||
# overridden in enterprise/app/models/enterprise/inbox.rb
|
||||
end
|
||||
|
||||
def delete_round_robin_agents
|
||||
::RoundRobin::ManageService.new(inbox: self).clear_queue
|
||||
end
|
||||
end
|
||||
|
||||
Inbox.prepend_mod_with('Inbox')
|
||||
|
||||
Reference in New Issue
Block a user