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/transfer.js

27 lines
824 B

import { hasPermissionAsync } from '../../../../authorization/server/functions/hasPermission';
import { Messages } from '../../../../models/server/raw';
const normalizeTransferHistory = ({ transferData }) => transferData;
export async function findLivechatTransferHistory({ userId, rid, pagination: { offset, count, sort } }) {
if (!await hasPermissionAsync(userId, 'view-livechat-rooms')) {
throw new Error('error-not-authorized');
}
const cursor = await Messages.find({ rid, t: 'livechat_transfer_history' }, {
fields: { transferData: 1 },
sort: sort || { ts: 1 },
skip: offset,
limit: count,
});
const total = await cursor.count();
const messages = await cursor.toArray();
const history = messages.map(normalizeTransferHistory);
return {
history,
count: history.length,
offset,
total,
};
}