diff --git a/app/lib/server/functions/addUserToRoom.js b/app/lib/server/functions/addUserToRoom.js index 2d97b88184db..69b7bd21f0ad 100644 --- a/app/lib/server/functions/addUserToRoom.js +++ b/app/lib/server/functions/addUserToRoom.js @@ -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); diff --git a/app/livechat/lib/LivechatRoomType.js b/app/livechat/lib/LivechatRoomType.js index 19dccc3201e9..1bcbe8bebc3b 100644 --- a/app/livechat/lib/LivechatRoomType.js +++ b/app/livechat/lib/LivechatRoomType.js @@ -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: diff --git a/app/livechat/server/startup.js b/app/livechat/server/startup.js index 8ae1e047bab8..1c05756727cc 100644 --- a/app/livechat/server/startup.js +++ b/app/livechat/server/startup.js @@ -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(); diff --git a/app/tokenpass/server/startup.js b/app/tokenpass/server/startup.js index 459cac9111fa..4ed4a9074315 100644 --- a/app/tokenpass/server/startup.js +++ b/app/tokenpass/server/startup.js @@ -47,7 +47,7 @@ Meteor.startup(function() { throw new Meteor.Error('error-not-allowed', 'Token required', { method: 'joinRoom' }); } - return room; + return user; }); }); diff --git a/packages/rocketchat-i18n/i18n/en.i18n.json b/packages/rocketchat-i18n/i18n/en.i18n.json index d6e264059b4e..115efd951e89 100644 --- a/packages/rocketchat-i18n/i18n/en.i18n.json +++ b/packages/rocketchat-i18n/i18n/en.i18n.json @@ -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",