From bce14bc09d1c67c92437232f6f1b80b2d0b13b8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Oliver=20J=C3=A4gle?= Date: Fri, 18 Aug 2017 06:19:57 +0200 Subject: [PATCH] Dirty hack for being able to delete an expertise. Fixes #58 The actual correction would be to provide a real authorization object, but that lead to exceptions which could not be corrected so far. Thus, this commit provides a short-term-low-risk-workaround. --- .../client/views/channelSettings.js | 7 +++++++ server/methods/eraseRoom.js | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/rocketchat-channel-settings/client/views/channelSettings.js b/packages/rocketchat-channel-settings/client/views/channelSettings.js index d24806ba20b2c..fae55df84318e 100644 --- a/packages/rocketchat-channel-settings/client/views/channelSettings.js +++ b/packages/rocketchat-channel-settings/client/views/channelSettings.js @@ -50,6 +50,13 @@ Template.channelSettings.helpers({ } }); const roomType = room && room.t; + /* + dirty hack since custom permissions create in packages/assistify-help-request/startup/customRoomTypes.js + lead to a streamer exception in some occasions. + */ + if (roomType === 'e') { + return roomType && RocketChat.authz.hasAtLeastOnePermission('delete-c'); + } return roomType && RocketChat.authz.hasAtLeastOnePermission(`delete-${ roomType }`, this.rid); }, readOnly() { diff --git a/server/methods/eraseRoom.js b/server/methods/eraseRoom.js index f6501542a292c..dcde275333360 100644 --- a/server/methods/eraseRoom.js +++ b/server/methods/eraseRoom.js @@ -17,7 +17,12 @@ Meteor.methods({ }); } - if (RocketChat.authz.hasPermission(fromId, `delete-${ room.t }`, rid)) { + /* + dirty hack since custom permissions create in packages/assistify-help-request/startup/customRoomTypes.js + lead to a streamer exception in some occasions. + */ + if ((room.t === 'e' && RocketChat.authz.hasPermission(fromId, 'delete-c', rid)) || + RocketChat.authz.hasPermission(fromId, `delete-${ room.t }`, rid)) { RocketChat.models.Messages.removeByRoomId(rid); RocketChat.models.Subscriptions.removeByRoomId(rid); return RocketChat.models.Rooms.removeById(rid);