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

30 lines
886 B

import { Meteor } from 'meteor/meteor';
import { check } from 'meteor/check';
import { LivechatTrigger } from '@rocket.chat/models';
import type { ServerMethods } from '@rocket.chat/ui-contexts';
import { hasPermissionAsync } from '../../../authorization/server/functions/hasPermission';
declare module '@rocket.chat/ui-contexts' {
// eslint-disable-next-line @typescript-eslint/naming-convention
interface ServerMethods {
'livechat:removeTrigger'(triggerId: string): boolean;
}
}
Meteor.methods<ServerMethods>({
async 'livechat:removeTrigger'(triggerId) {
const uid = Meteor.userId();
if (!uid || !(await hasPermissionAsync(uid, 'view-livechat-manager'))) {
throw new Meteor.Error('error-not-allowed', 'Not allowed', {
method: 'livechat:removeTrigger',
});
}
check(triggerId, String);
await LivechatTrigger.removeById(triggerId);
return true;
},
});