Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/authorization/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ Meteor.startup(function() {
{ _id: 'view-livechat-webhooks', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-facebook', roles: ['livechat-manager', 'admin'] },
{ _id: 'view-livechat-officeHours', roles: ['livechat-manager', 'admin'] },
Comment thread
MarcosSpessatto marked this conversation as resolved.
{ _id: 'view-livechat-closed-room-same-department', roles: ['livechat-manager', 'livechat-agent', 'admin'] },
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
{ _id: 'view-livechat-closed-room-by-another-agent', roles: ['livechat-manager', 'livechat-agent', 'admin'] },
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
];

for (const permission of permissions) {
Expand Down
24 changes: 24 additions & 0 deletions app/livechat/server/startup.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,27 @@ import { RoutingManager } from './lib/RoutingManager';
import { createLivechatQueueView } from './lib/Helper';
import { LivechatAgentActivityMonitor } from './statistics/LivechatAgentActivityMonitor';

function allowAccessClosedRoomOfSameDepartment(room, user) {
if (!room || !user || room.t !== 'l' || !room.departmentId || room.open) {
return;
}
const agentOfDepartment = LivechatDepartmentAgents.findOneByAgentIdAndDepartmentId(user._id, room.departmentId);
if (!agentOfDepartment) {
return;
}
return hasPermission(user._id, 'view-livechat-closed-room-same-department');
}

function allowAccessToClosedRoomsByAnotherAgent(room, user) {
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
if (!room || !user || room.t !== 'l' || room.open) {
return;
}
const { _id: userId } = user;
const { servedBy: { _id: agentId } = {} } = room;

return userId !== agentId && hasPermission(user._id, 'view-livechat-closed-room-by-another-agent');
}

Meteor.startup(() => {
roomTypes.setRoomFind('l', (_id) => LivechatRooms.findOneById(_id));

Expand Down Expand Up @@ -59,6 +80,9 @@ Meteor.startup(() => {
return inquiry && inquiry.status === 'queued';
});

addRoomAccessValidator(allowAccessClosedRoomOfSameDepartment);
addRoomAccessValidator(allowAccessToClosedRoomsByAnotherAgent);

callbacks.add('beforeLeaveRoom', function(user, room) {
if (room.t !== 'l') {
return user;
Expand Down
4 changes: 4 additions & 0 deletions app/models/server/models/LivechatDepartmentAgents.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class LivechatDepartmentAgents extends Base {
return this.find({ agentId });
}

findOneByAgentIdAndDepartmentId(agentId, departmentId) {
return this.findOne({ agentId, departmentId });
}

saveAgent(agent) {
return this.upsert({
agentId: agent.agentId,
Expand Down
2 changes: 2 additions & 0 deletions ee/app/livechat-enterprise/server/permissions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ export const createPermissions = () => {
'view-livechat-real-time-monitoring',
'view-livechat-officeHours',
'manage-livechat-agents',
'view-livechat-closed-room-same-department',
'view-livechat-closed-room-by-another-agent',
];


Expand Down
2 changes: 2 additions & 0 deletions packages/rocketchat-i18n/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3654,6 +3654,8 @@
"view-l-room": "View Omnichannel Rooms",
"view-l-room_description": "Permission to view Omnichannel rooms",
"view-livechat-analytics": "View Omnichannel Analytics",
"view-livechat-closed-room-by-another-agent": "View Omnichannel Closed Rooms by another agent",
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
"view-livechat-closed-room-same-department": "View Omnichannel Closed Rooms from the same department",
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
"view-livechat-departments": "View Omnichannel Departments",
"view-livechat-manager": "View Omnichannel Manager",
"view-livechat-manager_description": "Permission to view other Omnichannel managers",
Expand Down
4 changes: 3 additions & 1 deletion packages/rocketchat-i18n/i18n/pt-BR.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -3304,6 +3304,8 @@
"view-l-room": "Ver salas de Omnichannel",
"view-l-room_description": "Permissão para ver salas de Omnichannel",
"view-livechat-analytics": "Ver o Omnichannel Analytics",
"view-livechat-closed-room-by-another-agent": "Ver Salas Omnichannel fechadas por outro agente",
"view-livechat-closed-room-same-department": "Ver Salas Omnichannel fechadas do mesmo departamento",
Comment thread
MarcosSpessatto marked this conversation as resolved.
Outdated
"view-livechat-manager": "Ver o Gerente Omnichannel",
"view-livechat-manager_description": "Permissão para ver outros gerentes de Omnichannel",
"view-livechat-rooms": "Ver Salas de Omnichannel",
Expand Down Expand Up @@ -3429,4 +3431,4 @@
"Your_question": "A sua pergunta",
"Your_server_link": "O link do seu servidor",
"Your_workspace_is_ready": "O seu espaço de trabalho está pronto a usar 🎉"
}
}