From b552b1a12ffa806f21077172b07cb2870d4869ae Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Mon, 1 Sep 2025 21:06:18 +0530 Subject: [PATCH 1/2] chore!: remove deprecated getUserRoles method Signed-off-by: Abhinav Kumar --- apps/meteor/app/lib/server/index.ts | 1 - .../app/lib/server/methods/getUserRoles.ts | 29 ------------ apps/meteor/tests/end-to-end/api/methods.ts | 46 ------------------- 3 files changed, 76 deletions(-) delete mode 100644 apps/meteor/app/lib/server/methods/getUserRoles.ts diff --git a/apps/meteor/app/lib/server/index.ts b/apps/meteor/app/lib/server/index.ts index 551fd20e2545b..6efb675ebf83b 100644 --- a/apps/meteor/app/lib/server/index.ts +++ b/apps/meteor/app/lib/server/index.ts @@ -27,7 +27,6 @@ import './methods/getSingleMessage'; import './methods/getMessages'; import './methods/getSlashCommandPreviews'; import './methods/getUsernameSuggestion'; -import './methods/getUserRoles'; import './methods/joinDefaultChannels'; import './methods/joinRoom'; import './methods/leaveRoom'; diff --git a/apps/meteor/app/lib/server/methods/getUserRoles.ts b/apps/meteor/app/lib/server/methods/getUserRoles.ts deleted file mode 100644 index d9f8939611ac3..0000000000000 --- a/apps/meteor/app/lib/server/methods/getUserRoles.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { Authorization } from '@rocket.chat/core-services'; -import type { IUser } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; -import { Meteor } from 'meteor/meteor'; - -import { methodDeprecationLogger } from '../lib/deprecationWarningLogger'; - -declare module '@rocket.chat/ddp-client' { - // eslint-disable-next-line @typescript-eslint/naming-convention - interface ServerMethods { - getUserRoles(): Pick[]; - } -} - -Meteor.methods({ - async getUserRoles() { - methodDeprecationLogger.method( - 'getUserRoles', - '8.0.0', - 'This method is deprecated and will be removed in the future. Use the /v1/roles.getUsersInPublicRoles endpoint instead.', - ); - - if (!Meteor.userId()) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getUserRoles' }); - } - - return Authorization.getUsersFromPublicRoles(); - }, -}); diff --git a/apps/meteor/tests/end-to-end/api/methods.ts b/apps/meteor/tests/end-to-end/api/methods.ts index b9d99d9792aa0..113f140e40d0f 100644 --- a/apps/meteor/tests/end-to-end/api/methods.ts +++ b/apps/meteor/tests/end-to-end/api/methods.ts @@ -1314,52 +1314,6 @@ describe('Meteor.methods', () => { }); }); - describe('[@getUserRoles]', () => { - it('should fail if not logged in', (done) => { - void request - .post(methodCall('getUserRoles')) - .send({ - message: JSON.stringify({ - method: 'getUserRoles', - params: [], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(401) - .expect((res) => { - expect(res.body).to.have.property('status', 'error'); - expect(res.body).to.have.property('message'); - }) - .end(done); - }); - - it('should return the roles for the current user', (done) => { - void request - .post(methodCall('getUserRoles')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'getUserRoles', - params: [], - id: 'id', - msg: 'method', - }), - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.a.property('success', true); - expect(res.body).to.have.a.property('message').that.is.a('string'); - - const data = JSON.parse(res.body.message); - expect(data).to.have.a.property('result').that.is.an('array'); - }) - .end(done); - }); - }); - describe('[@listCustomUserStatus]', () => { it('should fail if not logged in', (done) => { void request From e4213bed06fbd98a6e41f3b5d0121c0bb91b1743 Mon Sep 17 00:00:00 2001 From: Abhinav Kumar Date: Mon, 1 Sep 2025 21:07:26 +0530 Subject: [PATCH 2/2] added changeset Signed-off-by: Abhinav Kumar --- .changeset/fresh-tables-raise.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/fresh-tables-raise.md diff --git a/.changeset/fresh-tables-raise.md b/.changeset/fresh-tables-raise.md new file mode 100644 index 0000000000000..89978df7f5421 --- /dev/null +++ b/.changeset/fresh-tables-raise.md @@ -0,0 +1,5 @@ +--- +'@rocket.chat/meteor': major +--- + +Removes the deprecated `getUserRoles` method in favor of the `/v1/roles.getUsersInPublicRoles` endpoint.