{"record":{"id":"e83dfdfbcdb6260c","repo":"RocketChat/Rocket.Chat","slug":"error-invalid-room-type-e83dfd","errorCode":"error-invalid-room-type","errorMessage":"${room.t} is not a valid room type","messagePattern":"(.+?) is not a valid room type","errorType":"exception","errorClass":"Meteor.Error","httpStatus":null,"severity":"error","filePath":"apps/meteor/server/meteor-methods/rooms/unmuteUserInRoom.ts","lineNumber":35,"sourceCode":"}\n\nexport const unmuteUserInRoom = async (fromId: string, data: { rid: IRoom['_id']; username: string }): Promise<boolean> => {\n\tif (!fromId || !(await hasPermissionAsync(fromId, 'mute-user', data.rid))) {\n\t\tthrow new Meteor.Error('error-not-allowed', 'Not allowed', {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t});\n\t}\n\n\tconst room = await Rooms.findOneById(data.rid);\n\n\tif (!room) {\n\t\tthrow new Meteor.Error('error-invalid-room', 'Invalid room', {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t});\n\t}\n\n\tif (!(await roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId))) {\n\t\tthrow new Meteor.Error('error-invalid-room-type', `${room.t} is not a valid room type`, {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t\ttype: room.t,\n\t\t});\n\t}\n\n\tconst subscription = await Subscriptions.findOneByRoomIdAndUsername(data.rid, data.username, {\n\t\tprojection: { _id: 1 },\n\t});\n\n\tif (!subscription) {\n\t\tthrow new Meteor.Error('error-user-not-in-room', 'User is not in this room', {\n\t\t\tmethod: 'unmuteUserInRoom',\n\t\t});\n\t}\n\n\tconst unmutedUser = await Users.findOneByUsernameIgnoringCase(data.username);\n\tif (!unmutedUser?.username) {\n\t\tthrow new Meteor.Error('error-invalid-user', 'Invalid user to unmute', {","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/RocketChat/Rocket.Chat/blob/b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0/apps/meteor/server/meteor-methods/rooms/unmuteUserInRoom.ts#L17-L53","documentation":"Before touching subscriptions, unmuteUserInRoom asks the room type's directives whether MUTE is an allowed member action: roomCoordinator.getRoomDirectives(room.t).allowMemberAction(room, RoomMemberActions.MUTE, fromId). When the type disallows it (direct messages, livechat rooms), it throws error-invalid-room-type with the type interpolated into the message, e.g. 'd is not a valid room type'.","triggerScenarios":"Calling Meteor.call('unmuteUserInRoom', { rid, username }) where the room is a direct message (t === 'd') or any other type whose directives do not allow the MUTE member action.","commonSituations":"Generic moderation tooling applied uniformly to all room types; users muted in a channel whose conversation moves to a DM where unmute is attempted; livechat guest rooms routed through channel moderation code.","solutions":["Only offer mute/unmute for room types that support it (channels and private groups)","Check room.t before invoking: skip the call entirely for 'd' and 'l' rooms","For DMs, drop the mute concept — nothing can be muted or unmuted there","When building generic moderation features, query roomCoordinator directives for supported actions per type"],"exampleFix":"// before\nMeteor.call('unmuteUserInRoom', { rid, username }); // rid is a direct message\n\n// after\nconst room = roomsCollection.findOne(rid);\nif (room && (room.t === 'c' || room.t === 'p')) {\n  Meteor.call('unmuteUserInRoom', { rid, username });\n}","handlingStrategy":"type-guard","validationCode":"// room loaded from the rooms collection before acting\nconst room = roomsCollection.findOne(rid);\nif (!room || !supportsMute(room)) {\n  // skip unmute entirely for 'd' (DMs), 'l' (livechat), etc.\n}","typeGuard":"const supportsMute = (room: { t: string }): boolean => room.t === 'c' || room.t === 'p';\n// channels and private groups allow the MUTE member action; DMs and livechat rooms do not","tryCatchPattern":"try {\n  await Meteor.callAsync('unmuteUserInRoom', { rid, username });\n} catch (error) {\n  if (error instanceof Meteor.Error && error.error === 'error-invalid-room-type') {\n    // this room type does not support mute/unmute; remove the action for it\n  }\n}","preventionTips":["Drive moderation menus from the room type's capabilities (roomCoordinator directives), not a fixed list","Never render mute/unmute controls in direct messages or livechat rooms","When building room-type-agnostic features, query allowMemberAction for each supported action"],"tags":["room-type","moderation","meteor-methods"],"backgroundTag":"invalid-room-type","analyzedSha":"b2c16d5842cbe6b69b59bdf6fc5e5f1afcd1f0b0","analyzedAt":"2026-08-18T15:26:39.429Z","contentChangedAt":"2026-08-18T15:26:39.429Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}