From 39b50c45d7b073e0421564ddb95211511f85ea63 Mon Sep 17 00:00:00 2001 From: Maki Nishifuji Date: Mon, 23 May 2016 22:11:31 +0900 Subject: [PATCH] Avoid exception if room not found --- server/methods/getRoomIdByNameOrId.coffee | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/server/methods/getRoomIdByNameOrId.coffee b/server/methods/getRoomIdByNameOrId.coffee index d41634ff71b..79e4946ff21 100644 --- a/server/methods/getRoomIdByNameOrId.coffee +++ b/server/methods/getRoomIdByNameOrId.coffee @@ -5,10 +5,12 @@ Meteor.methods room = RocketChat.models.Rooms.findOneById(rid) or RocketChat.models.Rooms.findOneByName(rid) + return null unless room? + 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 + 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: 'getRoomIdByNameOrId' } return room._id