mirror of
				https://github.com/lingble/chatwoot.git
				synced 2025-11-03 20:48:07 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			25 lines
		
	
	
		
			626 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
		
			626 B
		
	
	
	
		
			Ruby
		
	
	
	
	
	
class Api::V1::Accounts::AssignableAgentsController < Api::V1::Accounts::BaseController
 | 
						|
  before_action :fetch_inboxes
 | 
						|
 | 
						|
  def index
 | 
						|
    agent_ids = @inboxes.map do |inbox|
 | 
						|
      authorize inbox, :show?
 | 
						|
      member_ids = inbox.members.pluck(:user_id)
 | 
						|
      member_ids
 | 
						|
    end
 | 
						|
    agent_ids = agent_ids.inject(:&)
 | 
						|
    agents = Current.account.users.where(id: agent_ids)
 | 
						|
    @assignable_agents = (agents + Current.account.administrators).uniq
 | 
						|
  end
 | 
						|
 | 
						|
  private
 | 
						|
 | 
						|
  def fetch_inboxes
 | 
						|
    @inboxes = Current.account.inboxes.find(permitted_params[:inbox_ids])
 | 
						|
  end
 | 
						|
 | 
						|
  def permitted_params
 | 
						|
    params.permit(inbox_ids: [])
 | 
						|
  end
 | 
						|
end
 |