From edc395bfbed0f5fddc0b8ca75cff2b5326f7ecba Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Thu, 28 Aug 2025 11:28:52 -0300 Subject: [PATCH 1/4] chore!: remove meteor method `muteUserInRoom` --- apps/meteor/server/methods/muteUserInRoom.ts | 27 -------------------- 1 file changed, 27 deletions(-) diff --git a/apps/meteor/server/methods/muteUserInRoom.ts b/apps/meteor/server/methods/muteUserInRoom.ts index c9ae7e228c107..36e6a9e2c4ca1 100644 --- a/apps/meteor/server/methods/muteUserInRoom.ts +++ b/apps/meteor/server/methods/muteUserInRoom.ts @@ -1,12 +1,9 @@ import { Message } from '@rocket.chat/core-services'; import type { IRoom } from '@rocket.chat/core-typings'; -import type { ServerMethods } from '@rocket.chat/ddp-client'; import { Rooms, Subscriptions, Users } from '@rocket.chat/models'; -import { Match, check } from 'meteor/check'; import { Meteor } from 'meteor/meteor'; import { hasPermissionAsync } from '../../app/authorization/server/functions/hasPermission'; -import { methodDeprecationLogger } from '../../app/lib/server/lib/deprecationWarningLogger'; import { notifyOnRoomChangedById } from '../../app/lib/server/lib/notifyListener'; import { RoomMemberActions } from '../../definition/IRoomTypeConfig'; import { callbacks } from '../../lib/callbacks'; @@ -81,27 +78,3 @@ export const muteUserInRoom = async (fromId: string, data: { rid: IRoom['_id']; return true; }; - -Meteor.methods({ - async muteUserInRoom(data) { - methodDeprecationLogger.method('muteUserInRoom', '8.0.0', '/v1/rooms.muteUser'); - - check( - data, - Match.ObjectIncluding({ - rid: String, - username: String, - }), - ); - - const fromId = Meteor.userId(); - - if (!fromId) { - throw new Meteor.Error('error-invalid-user', 'Invalid user', { - method: 'muteUserInRoom', - }); - } - - return muteUserInRoom(fromId, data); - }, -}); From 23a282b05437bd77a457892ed61bd440d26f4ecc Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Thu, 28 Aug 2025 11:37:06 -0300 Subject: [PATCH 2/4] Create gold-zoos-sneeze.md --- .changeset/gold-zoos-sneeze.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/gold-zoos-sneeze.md diff --git a/.changeset/gold-zoos-sneeze.md b/.changeset/gold-zoos-sneeze.md new file mode 100644 index 0000000000000..ea4390ca7fb0b --- /dev/null +++ b/.changeset/gold-zoos-sneeze.md @@ -0,0 +1,5 @@ +--- +"@rocket.chat/meteor": patch +--- + +Removes deprecated meteor method `muteUserInRoom` From 24a396779fc8eee5ee613081b0820449fc5cc5f8 Mon Sep 17 00:00:00 2001 From: Martin Schoeler Date: Thu, 28 Aug 2025 11:37:28 -0300 Subject: [PATCH 3/4] Update gold-zoos-sneeze.md --- .changeset/gold-zoos-sneeze.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/gold-zoos-sneeze.md b/.changeset/gold-zoos-sneeze.md index ea4390ca7fb0b..a38ff5c5fb604 100644 --- a/.changeset/gold-zoos-sneeze.md +++ b/.changeset/gold-zoos-sneeze.md @@ -1,5 +1,5 @@ --- -"@rocket.chat/meteor": patch +"@rocket.chat/meteor": major --- Removes deprecated meteor method `muteUserInRoom` From 472dbd4493aae67348482e966d1114f1b904d8c9 Mon Sep 17 00:00:00 2001 From: MartinSchoeler Date: Thu, 28 Aug 2025 14:00:52 -0300 Subject: [PATCH 4/4] remove tests --- apps/meteor/tests/end-to-end/api/methods.ts | 235 -------------------- 1 file changed, 235 deletions(-) diff --git a/apps/meteor/tests/end-to-end/api/methods.ts b/apps/meteor/tests/end-to-end/api/methods.ts index ed282de1efdb5..7a607e9a23d61 100644 --- a/apps/meteor/tests/end-to-end/api/methods.ts +++ b/apps/meteor/tests/end-to-end/api/methods.ts @@ -3186,241 +3186,6 @@ describe('Meteor.methods', () => { }); }); - describe('[@muteUserInRoom & @unmuteUserInRoom]', () => { - let rid: IRoom['_id']; - let channelName: string; - let testUser: TestUser; - let testUserCredentials = {}; - - before('create test user', async () => { - const username = `user.test.${Date.now()}`; - const email = `${username}@rocket.chat`; - - testUser = await createUser({ email, name: username, username, password: username, roles: ['user'] }); - }); - - before('create channel', async () => { - channelName = `methods-test-channel-${Date.now()}`; - rid = (await createRoom({ type: 'c', name: channelName, members: [testUser.username] })).body.channel._id; - }); - - before('login testUser', async () => { - testUserCredentials = await login(testUser.username, testUser.username); - }); - - after(() => Promise.all([deleteRoom({ type: 'c', roomId: rid }), deleteUser(testUser)])); - - describe('-> standard room', () => { - describe('- when muting a user in a standard room', () => { - it('should mute an user in a standard room', async () => { - await request - .post(methodCall('muteUserInRoom')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'muteUserInRoom', - params: [{ rid, username: testUser.username }], - 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('msg', 'result'); - expect(data).to.have.a.property('id', 'id'); - expect(data).not.to.have.a.property('error'); - }); - }); - - it('muted user should not be able to send message', async () => { - await request - .post(api('chat.sendMessage')) - .set(testUserCredentials) - .send({ - message: { - msg: 'Sample message', - rid, - }, - }) - .expect('Content-Type', 'application/json') - .expect(400) - .expect((res) => { - expect(res.body).to.have.property('success', false); - expect(res.body).to.have.property('error').that.is.a('string'); - expect(res.body.error).to.equal('You_have_been_muted'); - }); - }); - }); - - describe('- when unmuting a user in a standard room', () => { - it('should unmute an user in a standard room', async () => { - await request - .post(methodCall('unmuteUserInRoom')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'unmuteUserInRoom', - params: [{ rid, username: testUser.username }], - 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('msg', 'result'); - expect(data).to.have.a.property('id', 'id'); - expect(data).not.to.have.a.property('error'); - }); - }); - - it('unmuted user should be able to send message', async () => { - await request - .post(api('chat.sendMessage')) - .set(testUserCredentials) - .send({ - message: { - msg: 'Sample message', - rid, - }, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - }); - }); - }); - }); - - describe('-> read-only room', () => { - before('set room to read-only', async () => { - await request - .post(api('channels.setReadOnly')) - .set(credentials) - .send({ - roomId: rid, - readOnly: true, - }) - .expect('Content-Type', 'application/json') - .expect(200); - }); - - it('should not allow an user to send messages', async () => { - await request - .post(api('chat.sendMessage')) - .set(testUserCredentials) - .send({ - message: { - msg: 'Sample message', - rid, - }, - }) - .expect('Content-Type', 'application/json') - .expect(400) - .expect((res) => { - expect(res.body).to.have.property('success', false); - expect(res.body).to.have.property('error').that.is.a('string'); - expect(res.body.error).to.equal(`You can't send messages because the room is readonly.`); - }); - }); - - describe('- when unmuting a user in a read-only room', () => { - it('should unmute an user in a read-only room', async () => { - await request - .post(methodCall('unmuteUserInRoom')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'unmuteUserInRoom', - params: [{ rid, username: testUser.username }], - 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('msg', 'result'); - expect(data).to.have.a.property('id', 'id'); - expect(data).not.to.have.a.property('error'); - }); - }); - - it('unmuted user in read-only room should be able to send message', async () => { - await request - .post(api('chat.sendMessage')) - .set(testUserCredentials) - .send({ - message: { - msg: 'Sample message', - rid, - }, - }) - .expect('Content-Type', 'application/json') - .expect(200) - .expect((res) => { - expect(res.body).to.have.property('success', true); - }); - }); - }); - - describe('- when muting a user in a read-only room', () => { - it('should mute an user in a read-only room', async () => { - await request - .post(methodCall('muteUserInRoom')) - .set(credentials) - .send({ - message: JSON.stringify({ - method: 'muteUserInRoom', - params: [{ rid, username: testUser.username }], - 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('msg', 'result'); - expect(data).to.have.a.property('id', 'id'); - expect(data).not.to.have.a.property('error'); - }); - }); - - it('muted user in read-only room should not be able to send message', async () => { - await request - .post(api('chat.sendMessage')) - .set(testUserCredentials) - .send({ - message: { - msg: 'Sample message', - rid, - }, - }) - .expect('Content-Type', 'application/json') - .expect(400) - .expect((res) => { - expect(res.body).to.have.property('success', false); - expect(res.body).to.have.property('error').that.is.a('string'); - }); - }); - }); - }); - }); - describe('[@saveSettings]', () => { it('should return an error when trying to save a "NaN" value', () => { void request