diff --git a/packages/rocketchat-authorization/server/methods/addUserToRole.coffee b/packages/rocketchat-authorization/server/methods/addUserToRole.coffee index 6a8baac97ec7..ac2d506654fa 100644 --- a/packages/rocketchat-authorization/server/methods/addUserToRole.coffee +++ b/packages/rocketchat-authorization/server/methods/addUserToRole.coffee @@ -11,6 +11,7 @@ Meteor.methods if not user?._id? throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'authorization:addUserToRole' } - RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: roleName, u: { _id: user._id, username: username }, scope: scope }); return RocketChat.models.Roles.addUserRoles user._id, roleName, scope diff --git a/packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee b/packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee index e9d66df8c17c..cbbfa8d66fc9 100644 --- a/packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee +++ b/packages/rocketchat-authorization/server/methods/removeUserFromRole.coffee @@ -11,6 +11,7 @@ Meteor.methods if not user?._id? throw new Meteor.Error 'error-invalid-user', 'Invalid user', { method: 'authorization:removeUserFromRole' } - RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: roleName, u: { _id: user._id, username: username }, scope: scope }); return RocketChat.models.Roles.removeUserRoles user._id, roleName, scope diff --git a/packages/rocketchat-authorization/server/methods/saveRole.coffee b/packages/rocketchat-authorization/server/methods/saveRole.coffee index d717d0601fd8..d646b4275f03 100644 --- a/packages/rocketchat-authorization/server/methods/saveRole.coffee +++ b/packages/rocketchat-authorization/server/methods/saveRole.coffee @@ -9,6 +9,7 @@ Meteor.methods if roleData.scope not in ['Users', 'Subscriptions'] roleData.scope = 'Users' - RocketChat.Notifications.notifyAll('roles-change', { type: 'changed', _id: roleData.name }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'changed', _id: roleData.name }); return RocketChat.models.Roles.createOrUpdate roleData.name, roleData.scope, roleData.description diff --git a/packages/rocketchat-lib/i18n/en.i18n.json b/packages/rocketchat-lib/i18n/en.i18n.json index 2b6a1e019c4e..7478c3b910d7 100644 --- a/packages/rocketchat-lib/i18n/en.i18n.json +++ b/packages/rocketchat-lib/i18n/en.i18n.json @@ -1015,6 +1015,7 @@ "True" : "True", "Type" : "Type", "Type_your_new_password" : "Type your new password", + "UI_DisplayRoles" : "Display Roles", "Unarchive" : "Unarchive", "Unmute_someone_in_room" : "Unmute someone in the room", "Unmute_user" : "Unmute user", diff --git a/packages/rocketchat-lib/server/startup/settings.coffee b/packages/rocketchat-lib/server/startup/settings.coffee index be5f98e389d2..7f91822b9c8a 100644 --- a/packages/rocketchat-lib/server/startup/settings.coffee +++ b/packages/rocketchat-lib/server/startup/settings.coffee @@ -192,6 +192,9 @@ RocketChat.settings.addGroup 'Layout', -> @add 'Custom_Script_Logged_Out', '//Add your script', { type: 'code', multiline: true, public: true } @add 'Custom_Script_Logged_In', '//Add your script', { type: 'code', multiline: true, public: true } + @section 'User Interface', -> + @add 'UI_DisplayRoles', true, { type: 'boolean', public: true } + RocketChat.settings.addGroup 'Logs', -> @add 'Debug_Level', 'error', { type: 'select', values: [ { key: 'error', i18nLabel: 'Only_errors' }, { key: 'debug', i18nLabel: 'All_logs' } ] } diff --git a/packages/rocketchat-ui-message/message/message.coffee b/packages/rocketchat-ui-message/message/message.coffee index 09874b7d470a..3d662bff4238 100644 --- a/packages/rocketchat-ui-message/message/message.coffee +++ b/packages/rocketchat-ui-message/message/message.coffee @@ -2,6 +2,8 @@ Template.message.helpers isBot: -> return 'bot' if this.bot? roleTags: -> + unless RocketChat.settings.get('UI_DisplayRoles') + return [] roles = _.union(UserRoles.findOne(this.u?._id)?.roles, RoomRoles.findOne({'u._id': this.u?._id, rid: this.rid })?.roles) return _.compact(_.map(roles, (role) -> return RocketChat.models.Roles.findOne({ _id: role, description: { $exists: 1 } })?.description)); isGroupable: -> diff --git a/server/methods/addRoomModerator.coffee b/server/methods/addRoomModerator.coffee index c60a0e9fd7b0..ca0f4fa24674 100644 --- a/server/methods/addRoomModerator.coffee +++ b/server/methods/addRoomModerator.coffee @@ -23,6 +23,7 @@ Meteor.methods username: fromUser.username role: 'moderator' - RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid }); return true diff --git a/server/methods/addRoomOwner.coffee b/server/methods/addRoomOwner.coffee index 5e18a4ec1d24..aba506c54970 100644 --- a/server/methods/addRoomOwner.coffee +++ b/server/methods/addRoomOwner.coffee @@ -23,6 +23,7 @@ Meteor.methods username: fromUser.username role: 'owner' - RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'added', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid }); return true diff --git a/server/methods/removeRoomModerator.coffee b/server/methods/removeRoomModerator.coffee index c7e06aa327b1..8ed1a1ac6037 100644 --- a/server/methods/removeRoomModerator.coffee +++ b/server/methods/removeRoomModerator.coffee @@ -23,6 +23,7 @@ Meteor.methods username: fromUser.username role: 'moderator' - RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'moderator', u: { _id: user._id, username: user.username }, scope: rid }); return true diff --git a/server/methods/removeRoomOwner.coffee b/server/methods/removeRoomOwner.coffee index ce975fafb2f0..063b9f43a5d3 100644 --- a/server/methods/removeRoomOwner.coffee +++ b/server/methods/removeRoomOwner.coffee @@ -27,6 +27,7 @@ Meteor.methods username: fromUser.username role: 'owner' - RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid }); + if RocketChat.settings.get('UI_DisplayRoles') + RocketChat.Notifications.notifyAll('roles-change', { type: 'removed', _id: 'owner', u: { _id: user._id, username: user.username }, scope: rid }); return true