The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/livechat/server/api/lib/agents.js

25 lines
668 B

import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission';
import { LivechatDepartmentAgents } from '../../../../models/server/raw';
export async function findAgentDepartments({ userId, agentId, pagination: { offset, count, sort } }) {
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,
};
}