More work on device connect/disconnect email notifications.
Ylian Saint-Hilaire committed
Oct 11, 2021 at 09:38 UTC
20b17b64b71cde42fce33f00e77756dc4c43464c
3 files changed
+36
-1
meshmail.js
+5
@@ -27,6 +27,7 @@ module.exports.CreateMeshMail = function (parent, domain) {
27
obj.verifyemail = false;
28
obj.domain = domain;
29
//obj.mailTemplates = {};
30
+ const sortCollator = new Intl.Collator(undefined, { numeric: true, sensitivity: 'base' })
31
const constants = (obj.parent.crypto.constants ? obj.parent.crypto.constants : require('constants')); // require('constants') is deprecated in Node 11.10, use require('crypto').constants instead.
32
33
function EscapeHtml(x) { if (typeof x == "string") return x.replace(/&/g, '&').replace(/>/g, '>').replace(/</g, '<').replace(/"/g, '"').replace(/'/g, '''); if (typeof x == "boolean") return x; if (typeof x == "number") return x; }
@@ -612,6 +613,10 @@ module.exports.CreateMeshMail = function (parent, domain) {
613
}
614
}
615
616
+ // Sort the notifications
617
+ connections.sort(sortCollator.compare);
618
+ disconnections.sort(sortCollator.compare);
619
+
620
// TODO: Send the email
621
//console.log('sendDeviceNotifications', connections, disconnections);
622
meshuser.js
+17
@@ -5663,6 +5663,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
5663
'dropallcira': [serverUserCommandDropAllCira, ""],
5664
'dupagents': [serverUserCommandDupAgents, ""],
5665
'email': [serverUserCommandEmail, ""],
5666
+ 'emailnotifications': [serverUserCommandEmailNotifications, ""],
5667
'firebase': [serverUserCommandFirebase, ""],
5668
'heapdump': [serverUserCommandHeapDump, ""],
5669
'heapdump2': [serverUserCommandHeapDump2, ""],
@@ -6053,6 +6054,22 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
6054
}
6055
}
6056
6057
+ function serverUserCommandEmailNotifications(cmdData) {
6058
+ if (domain.mailserver == null) {
6059
+ cmdData.result = "No email service enabled.";
6060
+ } else {
6061
+ var x = '';
6062
+ for (var userid in domain.mailserver.deviceNotifications) {
6063
+ x += userid + '\r\n';
6064
+ for (var nodeid in domain.mailserver.deviceNotifications[userid].nodes) {
6065
+ const info = domain.mailserver.deviceNotifications[userid].nodes[nodeid];
6066
+ x += ' ' + info.mn + ', ' + info.nn + ', c:' + (info.c ? info.c : 0) + ', d:' + (info.d ? info.d : 0) + '\r\n';
6067
+ }
6068
+ }
6069
+ cmdData.result = ((x == '')?'None':x);
6070
+ }
6071
+ }
6072
+
6073
function serverUserCommandLe(cmdData) {
6074
if (parent.parent.letsencrypt == null) {
6075
cmdData.result = "Let's Encrypt not in use.";
package.json
+14
-1
@@ -36,6 +36,8 @@
36
"sample-config-advanced.json"
37
],
38
"dependencies": {
39
+ "archiver": "^4.0.2",
40
+ "archiver-zip-encrypted": "^1.0.10",
41
"body-parser": "^1.19.0",
42
"cbor": "~5.2.0",
43
"compression": "^1.7.4",
@@ -43,13 +45,24 @@
45
"express": "^4.17.0",
46
"express-handlebars": "^3.1.0",
47
"express-ws": "^4.0.0",
48
+ "image-size": "^1.0.0",
49
"ipcheck": "^0.1.0",
50
+ "loadavg-windows": "^1.1.1",
51
"minimist": "^1.2.0",
52
+ "mongodb": "^4.1.0",
53
"multiparty": "^4.2.1",
54
"nedb": "^1.8.0",
55
"node-forge": "^0.10.0",
56
+ "node-rdpjs-2": "^0.3.5",
57
+ "node-windows": "^1.0.0-beta.6",
58
+ "nodemailer": "^6.6.5",
59
+ "otplib": "^10.2.3",
60
+ "saslprep": "^1.0.3",
61
+ "ssh2": "^1.4.0",
62
+ "web-push": "^3.4.5",
63
"ws": "^5.2.3",
52
- "yauzl": "^2.10.0"
64
+ "yauzl": "^2.10.0",
65
+ "yubikeyotp": "^0.2.0"
66
},
67
"repository": {
68
"type": "git",