[mirotalksfu] - extend email notification 4 widget
هذا الالتزام موجود في:
@@ -240,6 +240,10 @@ WIDGET_SUPPORT_ONLINE_TEXT=We are online # Online text
|
||||
WIDGET_SUPPORT_OFFLINE_TEXT=We are offline # Offline text
|
||||
WIDGET_SUPPORT_POWERED_BY=Powered by MiroTalk SFU # Powered by text
|
||||
|
||||
# Widget Alert Notifications
|
||||
WIDGET_ALERT_ENABLED=false # Enable alert notifications (true|false)
|
||||
WIDGET_ALERT_TYPE=email # Alert notification type (email) need EMAIL_ALERTS_ENABLED=true and configuration
|
||||
|
||||
# App
|
||||
UI_LANGUAGE=en # Interface language (en, es, fr, etc.)
|
||||
APP_NAME=MiroTalk SFU # Application name
|
||||
|
||||
@@ -64,7 +64,7 @@ dev dependencies: {
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.9.26
|
||||
* @version 1.9.27
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -172,6 +172,15 @@ const hostCfg = {
|
||||
presenters: config?.security?.host?.presenters,
|
||||
};
|
||||
|
||||
const widget = {
|
||||
enabled: config?.ui?.brand?.widget?.enabled,
|
||||
roomId: config?.ui?.brand?.widget?.roomId || 'support-room',
|
||||
alert: {
|
||||
enabled: config?.ui?.brand?.widget?.alert?.enabled,
|
||||
type: config?.ui?.brand?.widget?.alert?.type || 'email',
|
||||
},
|
||||
};
|
||||
|
||||
const restApi = {
|
||||
basePath: '/api/v1', // api endpoint path
|
||||
docs: host + '/api/v1/docs', // api docs
|
||||
@@ -1900,15 +1909,32 @@ function startServer() {
|
||||
}
|
||||
}
|
||||
|
||||
// SCENARIO: Notify when the first user join room and is awaiting assistance...
|
||||
if (room.getPeersCount() === 1) {
|
||||
nodemailer.sendEmailAlert('join', {
|
||||
room_id: room.id,
|
||||
peer_name: peer_name,
|
||||
domain: socket.handshake.headers.host.split(':')[0],
|
||||
os: os_name ? `${os_name} ${os_version}` : '',
|
||||
browser: browser_name ? `${browser_name} ${browser_version}` : '',
|
||||
}); // config.email.alert: true
|
||||
// Email body payload
|
||||
const emailPayload = {
|
||||
room_id: room.id,
|
||||
peer_name: peer_name,
|
||||
domain: socket.handshake.headers.host.split(':')[0],
|
||||
os: os_name ? `${os_name} ${os_version}` : '',
|
||||
browser: browser_name ? `${browser_name} ${browser_version}` : '',
|
||||
};
|
||||
|
||||
const firstJoin = room.getPeersCount() === 1;
|
||||
|
||||
// SCENARIO: Notify when the first user join room and is awaiting assistance
|
||||
if (firstJoin && !widget.alert.enabled) {
|
||||
nodemailer.sendEmailAlert('join', emailPayload);
|
||||
}
|
||||
|
||||
// SCENARIO: Notify when a user joins the widget room for expert assistance
|
||||
if (firstJoin && widget.enabled && widget.alert && widget.alert.enabled && widget.roomId === room.id) {
|
||||
switch (widget.alert.type) {
|
||||
case 'email':
|
||||
nodemailer.sendEmailAlert('widget', emailPayload);
|
||||
break;
|
||||
// case slack, discord, webhook, ...
|
||||
default:
|
||||
log.warn('Unknown alert type for widget', { type: widget.type });
|
||||
}
|
||||
}
|
||||
|
||||
// handle WebHook
|
||||
|
||||
@@ -1021,6 +1021,10 @@ module.exports = {
|
||||
poweredBy: process.env.WIDGET_SUPPORT_POWERED_BY || 'Powered by MiroTalk SFU',
|
||||
},
|
||||
},
|
||||
alert: {
|
||||
enabled: process.env.WIDGET_ALERT_ENABLED === 'true',
|
||||
type: process.env.WIDGET_ALERT_TYPE || 'email',
|
||||
},
|
||||
},
|
||||
|
||||
app: {
|
||||
|
||||
@@ -5,6 +5,8 @@ const config = require('../config');
|
||||
const Logger = require('../Logger');
|
||||
const log = new Logger('NodeMailer');
|
||||
|
||||
const APP_NAME = config.ui.brand.app.name || 'MiroTalk SFU';
|
||||
|
||||
// ####################################################
|
||||
// EMAIL CONFIG
|
||||
// ####################################################
|
||||
@@ -61,11 +63,14 @@ function sendEmailAlert(event, data) {
|
||||
subject = getJoinRoomSubject(data);
|
||||
body = getJoinRoomBody(data);
|
||||
break;
|
||||
case 'widget':
|
||||
subject = getWidgetRoomSubject(data);
|
||||
body = getWidgetRoomBody(data);
|
||||
break;
|
||||
case 'alert':
|
||||
subject = getAlertSubject(data);
|
||||
body = getAlertBody(data);
|
||||
break;
|
||||
//...
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -90,7 +95,7 @@ function sendEmail(subject, body) {
|
||||
|
||||
function getJoinRoomSubject(data) {
|
||||
const { room_id } = data;
|
||||
return `MiroTalk SFU - New user Join to Room ${room_id}`;
|
||||
return `${APP_NAME} - New user Join to Room ${room_id}`;
|
||||
}
|
||||
function getJoinRoomBody(data) {
|
||||
const { peer_name, room_id, domain, os, browser } = data;
|
||||
@@ -147,9 +152,26 @@ function getJoinRoomBody(data) {
|
||||
`;
|
||||
}
|
||||
|
||||
// ==========
|
||||
// Widget
|
||||
// ==========
|
||||
|
||||
function getWidgetRoomSubject(data) {
|
||||
const { room_id } = data;
|
||||
return `${APP_NAME} WIDGET - New user Wait for expert assistance in Room ${room_id}`;
|
||||
}
|
||||
|
||||
function getWidgetRoomBody(data) {
|
||||
return getJoinRoomBody(data);
|
||||
}
|
||||
|
||||
// ==========
|
||||
// Alert
|
||||
// ==========
|
||||
|
||||
function getAlertSubject(data) {
|
||||
const { subject } = data;
|
||||
return subject || 'MiroTalk SFU - Alert';
|
||||
return subject || `${APP_NAME} - Alert`;
|
||||
}
|
||||
|
||||
function getAlertBody(data) {
|
||||
|
||||
4
package-lock.json
مولّد
4
package-lock.json
مولّد
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "mirotalksfu",
|
||||
"version": "1.9.26",
|
||||
"version": "1.9.27",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "mirotalksfu",
|
||||
"version": "1.9.26",
|
||||
"version": "1.9.27",
|
||||
"license": "AGPL-3.0",
|
||||
"dependencies": {
|
||||
"@aws-sdk/client-s3": "^3.864.0",
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mirotalksfu",
|
||||
"version": "1.9.26",
|
||||
"version": "1.9.27",
|
||||
"description": "WebRTC SFU browser-based video calls",
|
||||
"main": "Server.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -99,7 +99,7 @@ let BRAND = {
|
||||
},
|
||||
about: {
|
||||
imageUrl: '../images/mirotalk-logo.gif',
|
||||
title: '<strong>WebRTC SFU v1.9.26</strong>',
|
||||
title: '<strong>WebRTC SFU v1.9.27</strong>',
|
||||
html: `
|
||||
<button
|
||||
id="support-button"
|
||||
|
||||
@@ -11,7 +11,7 @@ if (location.href.substr(0, 5) !== 'https') location.href = 'https' + location.h
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.9.26
|
||||
* @version 1.9.27
|
||||
*
|
||||
*/
|
||||
|
||||
@@ -5530,7 +5530,7 @@ function showAbout() {
|
||||
position: 'center',
|
||||
imageUrl: BRAND.about?.imageUrl && BRAND.about.imageUrl.trim() !== '' ? BRAND.about.imageUrl : image.about,
|
||||
customClass: { image: 'img-about' },
|
||||
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.9.26',
|
||||
title: BRAND.about?.title && BRAND.about.title.trim() !== '' ? BRAND.about.title : 'WebRTC SFU v1.9.27',
|
||||
html: `
|
||||
<br />
|
||||
<div id="about">
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
* @license For commercial or closed source, contact us at license.mirotalk@gmail.com or purchase directly via CodeCanyon
|
||||
* @license CodeCanyon: https://codecanyon.net/item/mirotalk-sfu-webrtc-realtime-video-conferences/40769970
|
||||
* @author Miroslav Pejic - miroslav.pejic.85@gmail.com
|
||||
* @version 1.9.26
|
||||
* @version 1.9.27
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
المرجع في مشكلة جديدة
حظر مستخدم