mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-22 12:52:50 +03:00
Added device help request messaging notification support.
This commit is contained in:
parent
1a6e78efed
commit
fbde2a87a5
@ -2322,7 +2322,7 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
// Check if any user needs email notification
|
// Check if any user needs email notification
|
||||||
for (var i in users) {
|
for (var i in users) {
|
||||||
const user = obj.webserver.users[users[i]];
|
const user = obj.webserver.users[users[i]];
|
||||||
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
if (user != null) {
|
||||||
var notify = 0;
|
var notify = 0;
|
||||||
|
|
||||||
// Device group notifications
|
// Device group notifications
|
||||||
@ -2336,7 +2336,7 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Email notifications
|
// Email notifications
|
||||||
if ((mailserver != null) && ((notify & 48) != 0)) {
|
if ((user.email != null) && (user.emailVerified == true) && (mailserver != null) && ((notify & 48) != 0)) {
|
||||||
if (stateSet == true) {
|
if (stateSet == true) {
|
||||||
if ((notify & 16) != 0) {
|
if ((notify & 16) != 0) {
|
||||||
mailserver.notifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
mailserver.notifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
@ -2384,7 +2384,7 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
const domainId = meshSplit[1];
|
const domainId = meshSplit[1];
|
||||||
if (obj.config.domains[domainId] == null) return;
|
if (obj.config.domains[domainId] == null) return;
|
||||||
const mailserver = obj.config.domains[domainId].mailserver;
|
const mailserver = obj.config.domains[domainId].mailserver;
|
||||||
if (mailserver == null) return;
|
if ((mailserver == null) && (obj.msgserver == null)) return;
|
||||||
|
|
||||||
// Get the device group for this device
|
// Get the device group for this device
|
||||||
const mesh = obj.webserver.meshes[meshid];
|
const mesh = obj.webserver.meshes[meshid];
|
||||||
@ -2404,7 +2404,7 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
// Check if any user needs email notification
|
// Check if any user needs email notification
|
||||||
for (var i in users) {
|
for (var i in users) {
|
||||||
const user = obj.webserver.users[users[i]];
|
const user = obj.webserver.users[users[i]];
|
||||||
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
if (user != null) {
|
||||||
var notify = 0;
|
var notify = 0;
|
||||||
|
|
||||||
// Device group notifications
|
// Device group notifications
|
||||||
@ -2417,9 +2417,11 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
if (user.notify[nodeid] != null) { notify |= user.notify[nodeid]; }
|
if (user.notify[nodeid] != null) { notify |= user.notify[nodeid]; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((notify & 64) != 0) {
|
// Mail help request
|
||||||
mailserver.sendDeviceHelpMail(domain, user.name, user.email, devicename, nodeid, helpusername, helprequest, user.llang);
|
if ((user.email != null) && (user.emailVerified == true) && ((notify & 64) != 0)) { mailserver.sendDeviceHelpMail(domain, user.name, user.email, devicename, nodeid, helpusername, helprequest, user.llang); }
|
||||||
}
|
|
||||||
|
// Message help request
|
||||||
|
if ((user.msghandle != null) && ((notify & 512) != 0)) { obj.msgserver.sendDeviceHelpRequest(domain, user.name, user.msghandle, devicename, nodeid, helpusername, helprequest, user.llang); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -442,6 +442,7 @@ module.exports.CreateServer = function (parent) {
|
|||||||
if (to == null) return;
|
if (to == null) return;
|
||||||
parent.debug('email', "Sending device state change message to " + to);
|
parent.debug('email', "Sending device state change message to " + to);
|
||||||
|
|
||||||
|
// Format the message
|
||||||
var sms = [];
|
var sms = [];
|
||||||
if (connections.length > 0) { sms.push('Connections: ' + connections.join(', ')); } // TODO: Translate 'Connections: '
|
if (connections.length > 0) { sms.push('Connections: ' + connections.join(', ')); } // TODO: Translate 'Connections: '
|
||||||
if (disconnections.length > 0) { sms.push('Disconnections: ' + disconnections.join(', ')); } // TODO: Translate 'Disconnections: '
|
if (disconnections.length > 0) { sms.push('Disconnections: ' + disconnections.join(', ')); } // TODO: Translate 'Disconnections: '
|
||||||
@ -453,6 +454,19 @@ module.exports.CreateServer = function (parent) {
|
|||||||
obj.sendMessage(to, sms, domain, null);
|
obj.sendMessage(to, sms, domain, null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Send help request notification
|
||||||
|
obj.sendDeviceHelpRequest = function (domain, username, to, devicename, nodeid, helpusername, helprequest, lang) {
|
||||||
|
if (to == null) return;
|
||||||
|
parent.debug('email', "Sending device help request message to " + to);
|
||||||
|
|
||||||
|
// Format the message
|
||||||
|
var sms = "Help Request from " + devicename + ': ' + helprequest; // TODO: Translate 'Help Request from {0}:'
|
||||||
|
if (sms.length > 1000) { sms = sms.substring(0, 997) + '...'; } // Limit messages to 1000 characters
|
||||||
|
|
||||||
|
// Send the message
|
||||||
|
obj.sendMessage(to, sms, domain, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Device connetion and disconnection notifications
|
// Device connetion and disconnection notifications
|
||||||
|
Loading…
Reference in New Issue
Block a user