feat: Assignable agents API (#2131)
`inboxes/id/assignable_agents` returns all users that have permission to a conversation happening in that inbox.
This commit is contained in:
@@ -7,6 +7,10 @@ class Api::V1::Accounts::InboxesController < Api::V1::Accounts::BaseController
|
||||
@inboxes = policy_scope(Current.account.inboxes.order_by_name.includes(:channel, { avatar_attachment: [:blob] }))
|
||||
end
|
||||
|
||||
def assignable_agents
|
||||
@assignable_agents = (Current.account.users.where(id: @inbox.members.select(:user_id)) + Current.account.administrators).uniq
|
||||
end
|
||||
|
||||
def create
|
||||
ActiveRecord::Base.transaction do
|
||||
channel = create_channel
|
||||
|
||||
@@ -23,6 +23,10 @@ class InboxPolicy < ApplicationPolicy
|
||||
true
|
||||
end
|
||||
|
||||
def assignable_agents?
|
||||
true
|
||||
end
|
||||
|
||||
def create?
|
||||
@account_user.administrator?
|
||||
end
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
json.payload do
|
||||
json.array! @assignable_agents do |agent|
|
||||
json.partial! 'api/v1/models/agent.json.jbuilder', resource: agent
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user