diff --git a/.changeset/fresh-tables-raise.md b/.changeset/fresh-tables-raise.md new file mode 100644 index 00000000000..89978df7f54 --- /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. diff --git a/apps/meteor/app/lib/server/index.ts b/apps/meteor/app/lib/server/index.ts index 551fd20e254..6efb675ebf8 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 d9f8939611a..00000000000 --- 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 036cdd3cc64..088aef3aeff 100644 --- a/apps/meteor/tests/end-to-end/api/methods.ts +++ b/apps/meteor/tests/end-to-end/api/methods.ts @@ -1339,52 +1339,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