Skip to content

Commit

Permalink
[FIX][ENTERPRISE] Omnichannel enterprise permissions being added back…
Browse files Browse the repository at this point in the history
… to its default roles (#22322)
  • Loading branch information
sampaiodiego committed Jun 28, 2021
1 parent 5b7cfb8 commit 4eee82c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 58 deletions.
48 changes: 24 additions & 24 deletions app/authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,37 +91,37 @@ Meteor.startup(function() {
{ _id: 'view-broadcast-member-list', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'call-management', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'create-invite-links', roles: ['admin', 'owner', 'moderator'] },
{ _id: 'view-l-room', roles: ['livechat-agent', 'livechat-manager', 'admin'] },
{ _id: 'view-livechat-manager', roles: ['livechat-manager', 'admin'] },
{ _id: 'edit-omnichannel-contact', roles: ['livechat-manager', 'admin', 'livechat-agent'] },
{ _id: 'view-livechat-rooms', roles: ['livechat-manager', 'admin'] },
{ _id: 'close-livechat-room', roles: ['livechat-agent', 'livechat-manager', 'admin'] },
{ _id: 'close-others-livechat-room', roles: ['livechat-manager', 'admin'] },
{ _id: 'on-hold-livechat-room', roles: ['livechat-agent', 'livechat-manager', 'admin'] },
{ _id: 'on-hold-others-livechat-room', roles: ['livechat-manager', 'admin'] },
{ _id: 'save-others-livechat-room-info', roles: ['livechat-manager'] },
{ _id: 'remove-closed-livechat-rooms', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-analytics', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-queue', roles: ['livechat-agent', 'livechat-manager', 'admin'] },
{ _id: 'transfer-livechat-guest', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-l-room', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'view-livechat-manager', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'edit-omnichannel-contact', roles: ['livechat-manager', 'livechat-agent', 'admin'] },
{ _id: 'view-livechat-rooms', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'close-livechat-room', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'close-others-livechat-room', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'on-hold-livechat-room', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'on-hold-others-livechat-room', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'save-others-livechat-room-info', roles: ['livechat-manager', 'livechat-monitor'] },
{ _id: 'remove-closed-livechat-rooms', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-analytics', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-queue', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'transfer-livechat-guest', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'manage-livechat-managers', roles: ['livechat-manager', 'admin'] },
{ _id: 'manage-livechat-agents', roles: ['livechat-manager', 'admin'] },
{ _id: 'manage-livechat-departments', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-departments', roles: ['livechat-manager', 'admin'] },
{ _id: 'add-livechat-department-agents', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-current-chats', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-real-time-monitoring', roles: ['livechat-manager', 'admin'] },
{ _id: 'manage-livechat-agents', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'manage-livechat-departments', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-departments', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'add-livechat-department-agents', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-current-chats', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-real-time-monitoring', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-triggers', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-customfields', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-installation', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-appearance', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-webhooks', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-facebook', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-business-hours', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-room-closed-same-department', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-room-closed-by-another-agent', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-room-customfields', roles: ['livechat-manager', 'livechat-agent', 'admin'] },
{ _id: 'edit-livechat-room-customfields', roles: ['livechat-manager', 'livechat-agent', 'admin'] },
{ _id: 'view-livechat-business-hours', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-room-closed-same-department', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-room-closed-by-another-agent', roles: ['livechat-manager', 'livechat-monitor', 'admin'] },
{ _id: 'view-livechat-room-customfields', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'edit-livechat-room-customfields', roles: ['livechat-manager', 'livechat-monitor', 'livechat-agent', 'admin'] },
{ _id: 'send-omnichannel-chat-transcript', roles: ['livechat-manager', 'admin'] },
{ _id: 'mail-messages', roles: ['admin'] },
{ _id: 'toggle-room-e2e-encryption', roles: ['owner'] },
Expand Down
36 changes: 2 additions & 34 deletions ee/app/livechat-enterprise/server/permissions.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import _ from 'underscore';

import { Permissions, Roles } from '../../../../app/models/server';

export const createPermissions = () => {
Expand All @@ -11,41 +9,11 @@ export const createPermissions = () => {
const livechatManagerRole = 'livechat-manager';
const adminRole = 'admin';

const roles = _.pluck(Roles.find().fetch(), 'name');
if (roles.indexOf(livechatMonitorRole) === -1) {
const monitorRole = Roles.findOneById(livechatMonitorRole, { fields: { _id: 1 } });
if (!monitorRole) {
Roles.createOrUpdate(livechatMonitorRole);
}

const permissions = [
'view-l-room',
'view-livechat-rooms',
'close-livechat-room',
'close-others-livechat-room',
'on-hold-livechat-room',
'on-hold-others-livechat-room',
'save-others-livechat-room-info',
'remove-closed-livechat-rooms',
'view-livechat-analytics',
'add-livechat-department-agents',
'view-livechat-queue',
'transfer-livechat-guest',
'view-livechat-manager',
'view-livechat-departments',
'view-livechat-current-chats',
'view-livechat-analytics',
'view-livechat-real-time-monitoring',
'view-livechat-business-hours',
'manage-livechat-agents',
'view-livechat-room-closed-same-department',
'view-livechat-room-closed-by-another-agent',
'view-livechat-room-customfields',
'edit-livechat-room-customfields',
'manage-livechat-departments',
];


permissions.map((p) => Permissions.addRole(p, livechatMonitorRole));

Permissions.create('manage-livechat-units', [adminRole, livechatManagerRole]);
Permissions.create('manage-livechat-monitors', [adminRole, livechatManagerRole]);
Permissions.create('manage-livechat-tags', [adminRole, livechatManagerRole]);
Expand Down

0 comments on commit 4eee82c

Please sign in to comment.