mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 16:06:33 +03:00
Completed per-device notification support. #3190
This commit is contained in:
parent
2a363c0f60
commit
9720f0758e
@ -2095,21 +2095,33 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
if ((mesh == null) || (mesh.links == null)) return;
|
if ((mesh == null) || (mesh.links == null)) return;
|
||||||
|
|
||||||
// Check if any user needs email notification
|
// Check if any user needs email notification
|
||||||
|
// TODO: Add user group support.
|
||||||
for (var i in mesh.links) {
|
for (var i in mesh.links) {
|
||||||
if (i.startsWith('user/')) {
|
if (i.startsWith('user/')) {
|
||||||
const user = obj.webserver.users[i];
|
const user = obj.webserver.users[i];
|
||||||
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
||||||
|
var notify = 0;
|
||||||
|
|
||||||
|
// Device group notifications
|
||||||
const meshLinks = user.links[meshid];
|
const meshLinks = user.links[meshid];
|
||||||
if ((meshLinks != null) && (meshLinks.notify != null) && ((meshLinks.notify & 48) != 0)) {
|
if ((meshLinks != null) && (meshLinks.notify != null)) { notify |= meshLinks.notify; }
|
||||||
|
|
||||||
|
// User notifications
|
||||||
|
if (user.notify != null) {
|
||||||
|
if (user.notify[meshid] != null) { notify |= user.notify[meshid]; }
|
||||||
|
if (user.notify[nodeid] != null) { notify |= user.notify[nodeid]; }
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((notify & 48) != 0) {
|
||||||
if (stateSet == true) {
|
if (stateSet == true) {
|
||||||
if ((meshLinks.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);
|
||||||
} else {
|
} else {
|
||||||
mailserver.cancelNotifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
mailserver.cancelNotifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (stateSet == false) {
|
else if (stateSet == false) {
|
||||||
if ((meshLinks.notify & 32) != 0) {
|
if ((notify & 32) != 0) {
|
||||||
mailserver.notifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
mailserver.notifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
} else {
|
} else {
|
||||||
mailserver.cancelNotifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
mailserver.cancelNotifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
|
@ -2130,8 +2130,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
// Handle any errors
|
// Handle any errors
|
||||||
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'changemeshnotify', responseid: command.responseid, result: err })); } catch (ex) { } } break; }
|
if (err != null) { if (command.responseid != null) { try { ws.send(JSON.stringify({ action: 'changemeshnotify', responseid: command.responseid, result: err })); } catch (ex) { } } break; }
|
||||||
|
|
||||||
// Change the notification (TODO: Add user group support, not sure how to do this here)
|
// Change the device group notification
|
||||||
// TODO (UserGroups)
|
|
||||||
if (user.links[command.meshid]) {
|
if (user.links[command.meshid]) {
|
||||||
if (command.notify == 0) {
|
if (command.notify == 0) {
|
||||||
delete user.links[command.meshid].notify;
|
delete user.links[command.meshid].notify;
|
||||||
@ -2140,6 +2139,10 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Change user notification if needed, this is needed then a user has device rights thru a user group
|
||||||
|
if ((command.notify == 0) && (user.notify != null) && (user.notify[command.meshid] != null)) { delete user.notify[command.meshid]; }
|
||||||
|
if ((command.notify != 0) && (user.links[command.meshid] == null)) { if (user.notify == null) { user.notify = {} } user.notify[command.meshid] = command.notify; }
|
||||||
|
|
||||||
// Save the user
|
// Save the user
|
||||||
parent.db.SetUser(user);
|
parent.db.SetUser(user);
|
||||||
|
|
||||||
|
17
package.json
17
package.json
@ -36,6 +36,9 @@
|
|||||||
"sample-config-advanced.json"
|
"sample-config-advanced.json"
|
||||||
],
|
],
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@yetzt/nedb": "^1.8.0",
|
||||||
|
"archiver": "^4.0.2",
|
||||||
|
"archiver-zip-encrypted": "^1.0.10",
|
||||||
"body-parser": "^1.19.0",
|
"body-parser": "^1.19.0",
|
||||||
"cbor": "~5.2.0",
|
"cbor": "~5.2.0",
|
||||||
"compression": "^1.7.4",
|
"compression": "^1.7.4",
|
||||||
@ -43,13 +46,23 @@
|
|||||||
"express": "^4.17.0",
|
"express": "^4.17.0",
|
||||||
"express-handlebars": "^3.1.0",
|
"express-handlebars": "^3.1.0",
|
||||||
"express-ws": "^4.0.0",
|
"express-ws": "^4.0.0",
|
||||||
|
"image-size": "^1.0.0",
|
||||||
"ipcheck": "^0.1.0",
|
"ipcheck": "^0.1.0",
|
||||||
|
"loadavg-windows": "^1.1.1",
|
||||||
"minimist": "^1.2.5",
|
"minimist": "^1.2.5",
|
||||||
|
"mongodb": "^4.1.0",
|
||||||
"multiparty": "^4.2.1",
|
"multiparty": "^4.2.1",
|
||||||
"@yetzt/nedb": "^1.8.0",
|
|
||||||
"node-forge": "^0.10.0",
|
"node-forge": "^0.10.0",
|
||||||
|
"node-rdpjs-2": "^0.3.5",
|
||||||
|
"node-windows": "^0.1.4",
|
||||||
|
"nodemailer": "^6.7.0",
|
||||||
|
"otplib": "^10.2.3",
|
||||||
|
"saslprep": "^1.0.3",
|
||||||
|
"ssh2": "^1.5.0",
|
||||||
|
"web-push": "^3.4.5",
|
||||||
"ws": "^5.2.3",
|
"ws": "^5.2.3",
|
||||||
"yauzl": "^2.10.0"
|
"yauzl": "^2.10.0",
|
||||||
|
"yubikeyotp": "^0.2.0"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
|
@ -2903,6 +2903,7 @@
|
|||||||
// If our list of nodes may have changes, request the new list now.
|
// If our list of nodes may have changes, request the new list now.
|
||||||
if (message.event.nodeListChange == userinfo._id) { meshserver.send({ action: 'nodes' }); }
|
if (message.event.nodeListChange == userinfo._id) { meshserver.send({ action: 'nodes' }); }
|
||||||
}
|
}
|
||||||
|
if (currentNode) { refreshDevice(currentNode._id); }
|
||||||
if (users == null) break;
|
if (users == null) break;
|
||||||
|
|
||||||
// Check if the account is part of our user group
|
// Check if the account is part of our user group
|
||||||
@ -2912,7 +2913,6 @@
|
|||||||
delete users[message.event.account._id]; // No longer part of our groups, remove this user.
|
delete users[message.event.account._id]; // No longer part of our groups, remove this user.
|
||||||
}
|
}
|
||||||
|
|
||||||
if (currentNode) { refreshDevice(currentNode._id); }
|
|
||||||
mainUpdate(4 | 16384);
|
mainUpdate(4 | 16384);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -7082,12 +7082,12 @@
|
|||||||
if (xxdialogMode) return false;
|
if (xxdialogMode) return false;
|
||||||
var devNotify = 0, fx = ((features2 & 0x00004000) && (userinfo.emailVerified))?1:0;
|
var devNotify = 0, fx = ((features2 & 0x00004000) && (userinfo.emailVerified))?1:0;
|
||||||
if (userinfo.notify && userinfo.notify[currentNode._id]) { devNotify = userinfo.notify[currentNode._id]; }
|
if (userinfo.notify && userinfo.notify[currentNode._id]) { devNotify = userinfo.notify[currentNode._id]; }
|
||||||
var x = '<div style="border-bottom: 1px solid #888;margin-bottom:3px">Web Page Notifications</div>';
|
var x = '<div style="border-bottom: 1px solid #888;margin-bottom:3px">' + "Web Page Notifications" + '</div>';
|
||||||
x += '<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
x += '<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
||||||
x += '<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
x += '<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
||||||
if (currentNode.intelamt != null) { fx += 2; x += '<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />' + "Intel® AMT desktop and serial events" + '</label></div>'; }
|
if (currentNode.intelamt != null) { fx += 2; x += '<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />' + "Intel® AMT desktop and serial events" + '</label></div>'; }
|
||||||
if (fx & 1) {
|
if (fx & 1) {
|
||||||
x += '<br /><div style="border-bottom: 1px solid #888;margin-bottom:3px">Email Notifications</div>';
|
x += '<br /><div style="border-bottom: 1px solid #888;margin-bottom:3px">' + "Email Notifications" + '</div>';
|
||||||
x += '<div><label><input id=p20enotifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
x += '<div><label><input id=p20enotifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
||||||
x += '<div><label><input id=p20enotifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
x += '<div><label><input id=p20enotifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
||||||
}
|
}
|
||||||
@ -11398,7 +11398,8 @@
|
|||||||
if ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 1024) == 0)) {
|
if ((userinfo.siteadmin == 0xFFFFFFFF) || ((userinfo.siteadmin & 1024) == 0)) {
|
||||||
// Display user notification
|
// Display user notification
|
||||||
var meshNotify = 0, meshNotifyStr = [];
|
var meshNotify = 0, meshNotifyStr = [];
|
||||||
if (userinfo.links && userinfo.links[currentMesh._id] && userinfo.links[currentMesh._id].notify) { meshNotify = userinfo.links[currentMesh._id].notify; }
|
if (userinfo.links && userinfo.links[currentMesh._id] && userinfo.links[currentMesh._id].notify) { meshNotify |= userinfo.links[currentMesh._id].notify; }
|
||||||
|
if (userinfo.notify && userinfo.notify[currentMesh._id]) { meshNotify |= userinfo.notify[currentMesh._id]; }
|
||||||
if (meshNotify & 2) { meshNotifyStr.push("Connect"); }
|
if (meshNotify & 2) { meshNotifyStr.push("Connect"); }
|
||||||
if (meshNotify & 4) { meshNotifyStr.push("Disconnect"); }
|
if (meshNotify & 4) { meshNotifyStr.push("Disconnect"); }
|
||||||
if (meshNotify & 8) { meshNotifyStr.push("Intel® AMT"); }
|
if (meshNotify & 8) { meshNotifyStr.push("Intel® AMT"); }
|
||||||
@ -12325,14 +12326,15 @@
|
|||||||
if (xxdialogMode) return false;
|
if (xxdialogMode) return false;
|
||||||
var meshNotify = 0;
|
var meshNotify = 0;
|
||||||
var emailNotify = ((features2 & 0x00004000) && (userinfo.emailVerified));
|
var emailNotify = ((features2 & 0x00004000) && (userinfo.emailVerified));
|
||||||
if (userinfo.links && userinfo.links[currentMesh._id] && userinfo.links[currentMesh._id].notify) { meshNotify = userinfo.links[currentMesh._id].notify; }
|
if (userinfo.links && userinfo.links[currentMesh._id] && userinfo.links[currentMesh._id].notify) { meshNotify |= userinfo.links[currentMesh._id].notify; }
|
||||||
|
if (userinfo.notify && userinfo.notify[currentMesh._id]) { meshNotify |= userinfo.notify[currentMesh._id]; }
|
||||||
//var x = "Notification settings must also be turned on in account settings." + '<br /><br />';
|
//var x = "Notification settings must also be turned on in account settings." + '<br /><br />';
|
||||||
var x = '<div style="border-bottom: 1px solid #888;margin-bottom:3px">Web Page Notifications</div>';
|
var x = '<div style="border-bottom: 1px solid #888;margin-bottom:3px">' + "Web Page Notifications" + '</div>';
|
||||||
x += '<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
x += '<div><label><input id=p20notifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
||||||
x += '<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
x += '<div><label><input id=p20notifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
||||||
x += '<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />' + "Intel® AMT desktop and serial events" + '</label></div>';
|
x += '<div><label><input id=p20notifyIntelAmtKvmActions type=checkbox />' + "Intel® AMT desktop and serial events" + '</label></div>';
|
||||||
if (emailNotify) {
|
if (emailNotify) {
|
||||||
x += '<br /><div style="border-bottom: 1px solid #888;margin-bottom:3px">Email Notifications</div>';
|
x += '<br /><div style="border-bottom: 1px solid #888;margin-bottom:3px">' + "Email Notifications" + '</div>';
|
||||||
x += '<div><label><input id=p20enotifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
x += '<div><label><input id=p20enotifyIntelDeviceConnect type=checkbox />' + "Device connections" + '</label></div>';
|
||||||
x += '<div><label><input id=p20enotifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
x += '<div><label><input id=p20enotifyIntelDeviceDisconnect type=checkbox />' + "Device disconnections" + '</label></div>';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user