Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NEW] Livechat notifications on new incoming inquiries for guest-pool #10588

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -45,4 +46,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