apps/meteor/app/livechat/server/methods/removeAgent.ts
import type { ServerMethods } from '@rocket.chat/ddp-client';
import { Meteor } from 'meteor/meteor';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { Livechat } from '../lib/LivechatTyped';
declare module '@rocket.chat/ddp-client' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:removeAgent'(username: string): boolean;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:removeAgent'(username) {
methodDeprecationLogger.method('livechat:removeAgent', '7.0.0');
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-agents'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:removeAgent',
});
}
return Livechat.removeAgent(username);
},
});