diff --git a/server/methods/getRoomIdByNameOrId.coffee b/server/methods/getRoomIdByNameOrId.coffee index 42ddad51275..bf94408cd2f 100644 --- a/server/methods/getRoomIdByNameOrId.coffee +++ b/server/methods/getRoomIdByNameOrId.coffee @@ -3,7 +3,10 @@ Meteor.methods room = RocketChat.models.Rooms.findOneById(rid) or RocketChat.models.Rooms.findOneByName(rid) + if room.usernames.indexOf(Meteor.user()?.username) isnt -1 + return room._id + if room?.t isnt 'c' or RocketChat.authz.hasPermission(Meteor.userId(), 'view-c-room') isnt true - throw new Meteor.Error 'error-not-allowed', 'Not allowed', { method: 'joinRoom' } + throw new Meteor.Error 'error-not-allowed', 'Not allowed', { method: 'getRoomIdByNameOrId' } return room._id