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/apps/meteor/app/livechat/server/methods/requestTranscript.ts

37 lines
1.1 KiB

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { Users } from '@rocket.chat/models';
import { Livechat } from '../lib/Livechat';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:requestTranscript'(rid: string, email: string, subject: string): Promise<boolean>;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:requestTranscript'(rid, email, subject) {
check(rid, String);
check(email, String);
const userId = Meteor.userId();
if (!userId || !(await hasPermissionAsync(userId, 'send-omnichannel-chat-transcript'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:requestTranscript',
});
}
const user = await Users.findOneById(userId, {
projection: { _id: 1, username: 1, name: 1, utcOffset: 1 },
});
await Livechat.requestTranscript({ rid, email, subject, user });
return true;
},
});