Skip to content

Commit

Permalink
Merge pull request #503 from assistify/fix/livechat-notifications-gue…
Browse files Browse the repository at this point in the history
…st-pool

[Livechat] Notify agents when a new chat is queued
  • Loading branch information
ruKurz authored Sep 13, 2018
2 parents 27d09db + 0640b78 commit cba977f
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 3 deletions.
4 changes: 3 additions & 1 deletion packages/rocketchat-lib/server/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
*/

import { RoomSettingsEnum, RoomTypeConfig, RoomTypeRouteConfig } from '../../lib/RoomTypeConfig';
import { sendNotification } from './sendNotificationsOnMessage.js';

export {
RoomSettingsEnum,
RoomTypeConfig,
RoomTypeRouteConfig
RoomTypeRouteConfig,
sendNotification
};
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,5 @@ function sendAllNotifications(message, room) {
}

RocketChat.callbacks.add('afterSaveMessage', sendAllNotifications, RocketChat.callbacks.priority.LOW, 'sendNotificationsOnMessage');

export {sendNotification};
3 changes: 2 additions & 1 deletion packages/rocketchat-livechat/.app/i18n/de.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"How_satisfied_were_you_with_this_chat": "Wie zufrieden sind Sie mit diesem Gespräch?",
"Installation": "Installation",
"New_messages": "Neue Nachrichten",
"New_livechat_in_queue": "Neuer Chat in der Wartschlange",
"No": "Nein",
"Options": "Optionen",
"Please_answer_survey": "Bitte nehmen Sie sich einen Moment Zeit, um kurz einige Fragen zu dem Gespräch zu beantworten.",
Expand Down Expand Up @@ -44,4 +45,4 @@
"Yes": "Ja",
"You": "Sie",
"You_must_complete_all_fields": "Sie müssen alle Felder ausfüllen"
}
}
3 changes: 2 additions & 1 deletion packages/rocketchat-livechat/.app/i18n/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"How_satisfied_were_you_with_this_chat": "How satisfied were you with this chat?",
"Installation": "Installation",
"New_messages": "New messages",
"New_livechat_in_queue": "New chat in queue",
"No": "No",
"Options": "Options",
"Please_answer_survey": "Please take a moment to answer a quick survey about this chat",
Expand Down Expand Up @@ -44,4 +45,4 @@
"Yes": "Yes",
"You": "You",
"You_must_complete_all_fields": "You must complete all fields"
}
}
21 changes: 21 additions & 0 deletions packages/rocketchat-livechat/server/lib/QueueMethods.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import _ from 'underscore';
import {sendNotification} from 'meteor/rocketchat:lib';

RocketChat.QueueMethods = {
/* Least Amount Queuing method:
Expand Down Expand Up @@ -141,6 +142,26 @@ RocketChat.QueueMethods = {
RocketChat.models.LivechatInquiry.insert(inquiry);
RocketChat.models.Rooms.insert(room);

// Alert the agents of the queued request
agentIds.forEach((agentId) => {
sendNotification({
//fake a subscription in order to make use of the function defined above
subscription: {
rid: room._id,
t : room.t,
u: {
_id : agentId
}
},
sender: room.v,
hasMentionToAll: true, //consider all agents to be in the room
hasMentionToHere: false,
message: Object.assign(message, {u: room.v}),
notificationMessage: message.msg,
room: Object.assign(room, {name: TAPi18n.__('New_livechat_in_queue')}),
mentionIds: []
});
});
return room;
},
'External'(guest, message, roomInfo, agent) {
Expand Down

0 comments on commit cba977f

Please sign in to comment.