Skip to content
Snippets Groups Projects
Unverified Commit 679efbb9 authored by Renato Becker's avatar Renato Becker Committed by Diego Sampaio
Browse files

[FIX] User can't invite or join other Omnichannel rooms (#18852)

parent 15af8d0d
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ export const addUserToRoom = function(rid, user, inviter, silenced) { ...@@ -31,7 +31,7 @@ export const addUserToRoom = function(rid, user, inviter, silenced) {
throw error; throw error;
} }
if (room.t === 'c' || room.t === 'p') { if (room.t === 'c' || room.t === 'p' || room.t === 'l') {
// Add a new event, with an optional inviter // Add a new event, with an optional inviter
callbacks.run('beforeAddedToRoom', { user, inviter }, room); callbacks.run('beforeAddedToRoom', { user, inviter }, room);
......
...@@ -5,7 +5,7 @@ import { ChatRoom } from '../../models'; ...@@ -5,7 +5,7 @@ import { ChatRoom } from '../../models';
import { settings } from '../../settings'; import { settings } from '../../settings';
import { hasPermission } from '../../authorization'; import { hasPermission } from '../../authorization';
import { openRoom } from '../../ui-utils'; import { openRoom } from '../../ui-utils';
import { RoomSettingsEnum, UiTextContext, RoomTypeRouteConfig, RoomTypeConfig } from '../../utils'; import { RoomMemberActions, RoomSettingsEnum, UiTextContext, RoomTypeRouteConfig, RoomTypeConfig } from '../../utils';
import { getAvatarURL } from '../../utils/lib/getAvatarURL'; import { getAvatarURL } from '../../utils/lib/getAvatarURL';
let LivechatInquiry; let LivechatInquiry;
...@@ -85,6 +85,10 @@ export default class LivechatRoomType extends RoomTypeConfig { ...@@ -85,6 +85,10 @@ export default class LivechatRoomType extends RoomTypeConfig {
} }
} }
allowMemberAction(room, action) {
return [RoomMemberActions.INVITE, RoomMemberActions.JOIN].includes(action);
}
getUiText(context) { getUiText(context) {
switch (context) { switch (context) {
case UiTextContext.HIDE_WARNING: case UiTextContext.HIDE_WARNING:
......
...@@ -83,6 +83,14 @@ Meteor.startup(async () => { ...@@ -83,6 +83,14 @@ Meteor.startup(async () => {
})); }));
}, callbacks.priority.LOW, 'cant-leave-room'); }, callbacks.priority.LOW, 'cant-leave-room');
callbacks.add('beforeJoinRoom', function(user, room) {
if (room.t === 'l' && !hasPermission(user._id, 'view-l-room')) {
throw new Meteor.Error('error-user-is-not-agent', 'User is not an Omnichannel Agent', { method: 'beforeJoinRoom' });
}
return user;
}, callbacks.priority.LOW, 'cant-join-room');
createLivechatQueueView(); createLivechatQueueView();
const monitor = new LivechatAgentActivityMonitor(); const monitor = new LivechatAgentActivityMonitor();
......
...@@ -47,7 +47,7 @@ Meteor.startup(function() { ...@@ -47,7 +47,7 @@ Meteor.startup(function() {
throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' }); throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' });
} }
return room; return user;
}); });
}); });
......
...@@ -1522,7 +1522,7 @@ ...@@ -1522,7 +1522,7 @@
"error-transcript-already-requested": "Transcript already requested", "error-transcript-already-requested": "Transcript already requested",
"error-user-has-no-roles": "User has no roles", "error-user-has-no-roles": "User has no roles",
"error-user-is-not-activated": "User is not activated", "error-user-is-not-activated": "User is not activated",
"error-user-is-not-agent": "User is not a Omnichannel Agent", "error-user-is-not-agent": "User is not an Omnichannel Agent",
"error-user-is-offline": "User if offline", "error-user-is-offline": "User if offline",
"error-user-limit-exceeded": "The number of users you are trying to invite to #channel_name exceeds the limit set by the administrator", "error-user-limit-exceeded": "The number of users you are trying to invite to #channel_name exceeds the limit set by the administrator",
"error-user-not-in-room": "User is not in this room", "error-user-not-in-room": "User is not in this room",
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment