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/server/lib/roles/validateRoleList.ts

13 lines
432 B

import type { IRole } from '@rocket.chat/core-typings';
import { Roles } from '@rocket.chat/models';
export const validateRoleList = async (roleIds: IRole['_id'][]): Promise<boolean> => {
const options = {
projection: {
_id: 1,
},
};
const existingRoleIds = (await Roles.findInIds<Pick<IRole, '_id'>>(roleIds, options).toArray()).map(({ _id }) => _id);
return !roleIds.find((_id) => !existingRoleIds.includes(_id));
};