Skip to content

Commit cb8b539

Browse files
authored
Merge pull request RocketChat#584 from WideChat/kill_bot_switch
[NEW] Livechat agent communication disable switch
2 parents 082c8c2 + fd537e1 commit cb8b539

File tree

8 files changed

+38
-4
lines changed

8 files changed

+38
-4
lines changed

app/livechat/server/api/lib/livechat.js

+2
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,8 @@ export function settings(url) {
145145
return {
146146
enabled: initSettings.Livechat_enabled,
147147
settings: {
148+
emergencyLivechatDisable: initSettings.Livechat_kill_switch,
149+
emergencyLivechatDisableMessage: initSettings.Livechat_kill_switch_message,
148150
registrationForm: shouldShowRegistrationForm(),
149151
startSessionOnNewChat: initSettings.Livechat_start_session_on_new_chat,
150152
allowSwitchingDepartments: initSettings.Livechat_allow_switching_departments,

app/livechat/server/config.js

+15
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@ Meteor.startup(function() {
1919
public: true,
2020
});
2121

22+
settings.add('Livechat_kill_switch', false, {
23+
type: 'boolean',
24+
group: 'Omnichannel',
25+
section: 'Livechat',
26+
public: true,
27+
i18nDescription: 'Temporary_livechat_shutdown',
28+
});
29+
30+
settings.add('Livechat_kill_switch_message', 'Livechat is currently offline', {
31+
type: 'string',
32+
group: 'Omnichannel',
33+
section: 'Livechat',
34+
public: true,
35+
});
36+
2237
settings.add('Livechat_title_color', '#C1272D', {
2338
type: 'color',
2439
editor: 'color',

app/livechat/server/hooks/beforeDelegateAgent.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ import { Users, LivechatDepartmentAgents } from '../../../models';
55

66
callbacks.add('livechat.beforeDelegateAgent', (options = {}) => {
77
const { department, agent } = options;
8-
8+
if (!settings.get('Livechat_kill_switch')) {
9+
return null;
10+
}
911
if (agent) {
1012
return agent;
1113
}

app/livechat/server/hooks/leadCapture.js

+9
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
1+
import { Meteor } from 'meteor/meteor';
2+
13
import { callbacks } from '../../../callbacks';
24
import { settings } from '../../../settings';
35
import { LivechatVisitors } from '../../../models';
46

7+
58
function validateMessage(message, room) {
69
// skips this callback if the message was edited
710
if (message.editedAt) {
@@ -45,3 +48,9 @@ callbacks.add('afterSaveMessage', function(message, room) {
4548

4649
return message;
4750
}, callbacks.priority.LOW, 'leadCapture');
51+
52+
callbacks.add('beforeSaveMessage', () => {
53+
if (settings.get('Livechat_kill_switch')) {
54+
throw new Meteor.Error(settings.get('Livechat_kill_switch_message'));
55+
}
56+
}, callbacks.priority.MEDIUM, 'leadCapture');

app/livechat/server/lib/Livechat.js

+2
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,8 @@ export const Livechat = {
469469
const rcSettings = {};
470470

471471
Settings.findNotHiddenPublic([
472+
'Livechat_kill_switch',
473+
'Livechat_kill_switch_message',
472474
'Livechat_title',
473475
'Livechat_title_color',
474476
'Livechat_enable_message_character_limit',

app/livechat/server/lib/routing/AutoSelection.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RoutingManager } from '../RoutingManager';
22
import { LivechatDepartmentAgents, Users } from '../../../../models/server';
3+
import { settings } from '../../../../settings/server';
34

45
/* Auto Selection Queuing method:
56
*
@@ -20,10 +21,12 @@ class AutoSelection {
2021
}
2122

2223
getNextAgent(department, ignoreAgentId) {
24+
if (!settings.get('Livechat_kill_switch')) {
25+
return;
26+
}
2327
if (department) {
2428
return LivechatDepartmentAgents.getNextAgentForDepartment(department, ignoreAgentId);
2529
}
26-
2730
return Users.getNextAgent(ignoreAgentId);
2831
}
2932
}

app/livechat/server/lib/routing/External.js

-2
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,8 @@ class ExternalQueue {
3333
'X-RocketChat-Secret-Token': settings.get('Livechat_External_Queue_Token'),
3434
},
3535
});
36-
3736
if (result && result.data && result.data.username) {
3837
const agent = Users.findOneOnlineAgentByUsername(result.data.username);
39-
4038
if (agent) {
4139
return {
4240
agentId: agent._id,

packages/rocketchat-i18n/i18n/en.i18n.json

+3
Original file line numberDiff line numberDiff line change
@@ -2429,6 +2429,8 @@
24292429
"Livechat_DepartmentOfflineMessageToChannel": "Send this department's Livechat offline messages to a channel",
24302430
"Livechat_enable_message_character_limit": "Enable message character limit",
24312431
"Livechat_enabled": "Omnichannel enabled",
2432+
"Livechat_kill_switch": "Disable Livechat",
2433+
"Livechat_kill_switch_message": "Disable Livechat Message",
24322434
"Livechat_Facebook_API_Key": "OmniChannel API Key",
24332435
"Livechat_Facebook_API_Secret": "OmniChannel API Secret",
24342436
"Livechat_Facebook_Enabled": "Facebook integration enabled",
@@ -3742,6 +3744,7 @@
37423744
"Technology_Provider": "Technology Provider",
37433745
"Technology_Services": "Technology Services",
37443746
"Telecom": "Telecom",
3747+
"Temporary_livechat_shutdown": "Temporarily disable livechat communication between users and agents",
37453748
"Terms": "Terms",
37463749
"Test_Connection": "Test Connection",
37473750
"Test_Desktop_Notifications": "Test Desktop Notifications",

0 commit comments

Comments
 (0)