Rocket.Chat/apps/meteor/tests/data/roles.helper.ts
Abhinav Kumar c8e8518011
Some checks failed
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / Builds matrix rust bindings against alpine (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / deploy-preview (push) Has been cancelled
CI / 📦 Meteor Build - coverage (push) Has been cancelled
CI / 📦 Meteor Build - official (push) Has been cancelled
CI / 🚢 Build Docker Images for Testing (alpine) (push) Has been cancelled
CI / 🚢 Build Docker Images for Production (alpine) (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Image (main) (alpine) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (account) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (authorization) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (ddp-streamer) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (omnichannel-transcript) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (presence) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (queue-worker) (push) Has been cancelled
CI / 🚀 Publish Docker Image (services) (stream-hub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / trigger-dependent-workflows (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
feat: add endpoint rooms.membersOrderedByRole (#34153)
Co-authored-by: Martin Schoeler <20868078+MartinSchoeler@users.noreply.github.com>
2025-01-17 21:27:44 +00:00

42 lines
1.2 KiB
TypeScript

import type { Credentials } from '@rocket.chat/api-client';
import type { IRole } from '@rocket.chat/core-typings';
import { api, credentials, request } from './api-data';
export const createCustomRole = async ({
name,
scope,
description,
credentials: customCredentials,
}: Pick<IRole, 'name' | 'scope' | 'description'> & { credentials?: Credentials }) => {
const response = await request
.post(api('roles.create'))
.set(customCredentials || credentials)
.send({ name, scope, description });
return response.body.role as IRole;
};
export const deleteCustomRole = async ({ roleId, credentials: customCredentials }: { roleId: IRole['_id']; credentials?: Credentials }) => {
const response = await request
.post(api('roles.delete'))
.set(customCredentials || credentials)
.send({ roleId });
return response.body.success as boolean;
};
export const assignRoleToUser = async ({
username,
roleId,
credentials: customCredentials,
}: {
username: string;
roleId: string;
credentials?: Credentials;
}) => {
const response = await request
.post(api('roles.addUserToRole'))
.set(customCredentials || credentials)
.send({ username, roleId });
return response.body.success as boolean;
};