[IMPROVE] Replace forgotten livechat:departmentAgents subscriptions (#15970)
* Replace forgotten livechat:departmentAgents subscriptions * Get agent id from room object * Regression: Continue using the userId to fetch the agent departments.pull/15503/head
parent
a4c60b5e32
commit
569279ec2d
@ -1,3 +0,0 @@ |
||||
import { Mongo } from 'meteor/mongo'; |
||||
|
||||
export const LivechatDepartmentAgents = new Mongo.Collection('rocketchat_livechat_department_agents'); |
||||
@ -1,25 +1,12 @@ |
||||
import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission'; |
||||
import { LivechatDepartmentAgents } from '../../../../models/server/raw'; |
||||
|
||||
export async function findAgentDepartments({ userId, agentId, pagination: { offset, count, sort } }) { |
||||
export async function findAgentDepartments({ userId, agentId }) { |
||||
if (!await hasPermissionAsync(userId, 'view-l-room')) { |
||||
throw new Error('error-not-authorized'); |
||||
} |
||||
|
||||
const cursor = LivechatDepartmentAgents.find({ agentId }, { |
||||
sort: sort || { name: 1 }, |
||||
skip: offset, |
||||
limit: count, |
||||
}); |
||||
|
||||
const total = await cursor.count(); |
||||
|
||||
const departments = await cursor.toArray(); |
||||
|
||||
return { |
||||
departments, |
||||
count: departments.length, |
||||
offset, |
||||
total, |
||||
departments: await LivechatDepartmentAgents.find({ agentId }).toArray(), |
||||
}; |
||||
} |
||||
|
||||
Loading…
Reference in new issue