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/removeDepartment.ts

33 lines
1.1 KiB

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import type { DeleteResult } from 'mongodb';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
import { methodDeprecationLogger } from '../../../lib/server/lib/deprecationWarningLogger';
import { DepartmentHelper } from '../lib/Departments';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:removeDepartment'(_id: string): DeleteResult;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:removeDepartment'(_id) {
methodDeprecationLogger.method('livechat:removeDepartment', '7.0.0');
check(_id, String);
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'manage-livechat-departments'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:removeDepartment',
});
}
return DepartmentHelper.removeDepartment(_id);
},
});