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

pull/18867/head
Renato Becker 5 years ago committed by Diego Sampaio
parent 15af8d0d34
commit 679efbb927
No known key found for this signature in database
GPG Key ID: E060152B30502562
  1. 2
      app/lib/server/functions/addUserToRoom.js
  2. 6
      app/livechat/lib/LivechatRoomType.js
  3. 8
      app/livechat/server/startup.js
  4. 2
      app/tokenpass/server/startup.js
  5. 2
      packages/rocketchat-i18n/i18n/en.i18n.json

@ -31,7 +31,7 @@ export const addUserToRoom = function(rid, user, inviter, silenced) {
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
callbacks.run('beforeAddedToRoom', { user, inviter }, room);

@ -5,7 +5,7 @@ import { ChatRoom } from '../../models';
import { settings } from '../../settings';
import { hasPermission } from '../../authorization';
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';
let LivechatInquiry;
@ -85,6 +85,10 @@ export default class LivechatRoomType extends RoomTypeConfig {
}
}
allowMemberAction(room, action) {
return [RoomMemberActions.INVITE, RoomMemberActions.JOIN].includes(action);
}
getUiText(context) {
switch (context) {
case UiTextContext.HIDE_WARNING:

@ -83,6 +83,14 @@ Meteor.startup(async () => {
}));
}, 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();
const monitor = new LivechatAgentActivityMonitor();

@ -47,7 +47,7 @@ Meteor.startup(function() {
throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' });
}
return room;
return user;
});
});

@ -1522,7 +1522,7 @@
"error-transcript-already-requested": "Transcript already requested",
"error-user-has-no-roles": "User has no roles",
"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-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",

Loading…
Cancel
Save