Skip to content

Commit

Permalink
[NEW] Livechat notifications on new incoming inquiries for guest-pool (
Browse files Browse the repository at this point in the history
  • Loading branch information
mrsimpson authored and sampaiodiego committed Sep 20, 2018
1 parent e599ab7 commit b5e3802
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 2 deletions.
2 changes: 2 additions & 0 deletions 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,
sendNotification,
};
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,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 @@ -17,6 +17,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 @@ -46,4 +47,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 @@ -149,6 +150,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 b5e3802

Please sign in to comment.