ntfy improvements.
Ylian Saint-Hilaire committed
Oct 31, 2022 at 14:28 UTC
6b8acc16753f430567023bf55668c1d33db5e36a
4 files changed
+46
-3
meshcentral-config-schema.json
+38
@@ -1379,6 +1379,44 @@
1379
"token": { "type": "string", "description": "A Discord bot token that MeshCentral will use to login to Discord." }
1380
},
1381
"required": [ "token" ]
1382
+ },
1383
+ "xmpp": {
1384
+ "type": "object",
1385
+ "description": "Configure XMPP messaging system",
1386
+ "properties": {
1387
+ "service": { "type": "string", "description": "Host name of the XMPP server." },
1388
+ "credentials": {
1389
+ "type": "object",
1390
+ "description": "Login credentials for the XMPP server.",
1391
+ "properties": {
1392
+ "username": { "type": "string" },
1393
+ "password": { "type": "string" }
1394
+ }
1395
+ }
1396
+ },
1397
+ "required": [ "credentials" ]
1398
+ },
1399
+ "callmebot": {
1400
+ "type": "boolean",
1401
+ "default": false,
1402
+ "description": "Enabled CallMeBot integration support."
1403
+ },
1404
+ "pushover": {
1405
+ "type": "object",
1406
+ "description": "Configure Pushover messaging system",
1407
+ "properties": {
1408
+ "token": { "type": "string", "description": "A Pushover application token that MeshCentral will use to login." }
1409
+ },
1410
+ "required": [ "token" ]
1411
+ },
1412
+ "ntfy": {
1413
+ "type": [ "boolean", "object" ],
1414
+ "default": false,
1415
+ "properties": {
1416
+ "host": { "type": "string", "description": "Host name of the ntfy server." },
1417
+ "userurl": { "type": "string", "description": "A URL given to users to help them setup this service." }
1418
+ },
1419
+ "description": "Enabled ntfy.sh integration support."
1420
}
1421
}
1422
}
meshmessaging.js
+2
-1
@@ -292,7 +292,8 @@ module.exports.CreateServer = function (parent) {
292
const push = new Pushover({ token: parent.config.messaging.pushover.token, user: to.substring(9) });
293
push.send(domain.title ? domain.title : 'MeshCentral', msg, function (err, res) { if (func != null) { func(err == null); } });
294
} else if ((to.startsWith('ntfy:')) && (obj.ntfyClient != null)) { // ntfy
295
- const req = require('https').request(new URL('https://ntfy.sh/' + encodeURIComponent(to.substring(5))), { method: 'POST' }, function (res) { if (func != null) { func(true); } });
295
+ const url = 'https://' + (((typeof parent.config.messaging.ntfy == 'object') && (typeof parent.config.messaging.ntfy.host == 'string')) ? parent.config.messaging.ntfy.host : 'ntfy.sh') + '/' + encodeURIComponent(to.substring(5));
296
+ const req = require('https').request(new URL(url), { method: 'POST' }, function (res) { if (func != null) { func(true); } });
297
req.on('error', function (err) { if (func != null) { func(false); } });
298
req.end(msg);
299
} else {
meshuser.js
+3
@@ -579,6 +579,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
579
serverinfo.userMsgProviders = parent.parent.msgserver.providers;
580
if (parent.parent.msgserver.discordUrl != null) { serverinfo.discordUrl = parent.parent.msgserver.discordUrl; }
581
}
582
+ if ((typeof parent.parent.config.messaging == 'object') && (typeof parent.parent.config.messaging.ntfy == 'object') && (typeof parent.parent.config.messaging.ntfy.userurl == 'string')) { // nfty user url
583
+ serverinfo.userMsgNftyUrl = parent.parent.config.messaging.ntfy.userurl;
584
+ }
585
586
// Build the mobile agent URL, this is used to connect mobile devices
587
var agentServerName = parent.getWebServerName(domain, req);
views/default.handlebars
+3
-2
@@ -11995,7 +11995,8 @@
11995
if (serverinfo.discordUrl) { x += '<div id=d2discordurl style=display:none><br /><a href=' + serverinfo.discordUrl + ' target="_discord">' + "Join this Discord server to receive notifications." + '</a></div>'; }
11996
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a></div>';
11997
x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
11998
- x += '<div id=d2ntfyinfo style=display:none><br /><a href=https://ntfy.sh/ target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
11998
+ console.log(serverinfo.userMsgNftyUrl);
11999
+ x += '<div id=d2ntfyinfo style=display:none><br /><a href="' + (serverinfo.userMsgNftyUrl ? serverinfo.userMsgNftyUrl : 'https://ntfy.sh/') + '" target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
12000
setDialogMode(2, "Messaging Notifications", 3, account_manageMessagingAdd, x, 'verifyMessaging');
12001
Q('d2handleinput').focus();
12002
account_manageMessagingValidate();
@@ -15884,7 +15885,7 @@
15885
if (serverinfo.discordUrl) { x += '<div id=d2discordurl style=display:none><br /><a href=' + serverinfo.discordUrl + ' target="_discord">' + "Join this Discord server to receive notifications." + '</a></div>' }
15886
x += '<div id=d2callmebotinfo style=display:none><br /><a href=https://www.callmebot.com/blog/free-api-signal-send-messages/ target="_callmebot">' + "Signal" + '</a>, <a href=https://www.callmebot.com/blog/free-api-whatsapp-messages/ target="_callmebot">' + "Whatsapp" + '</a>, <a href=https://www.callmebot.com/blog/free-api-facebook-messenger/ target="_callmebot">' + "Facebook" + '</a></div>';
15887
x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
15887
- x += '<div id=d2ntfyinfo style=display:none><br /><a href=https://ntfy.sh/ target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
15888
+ x += '<div id=d2ntfyinfo style=display:none><br /><a href="' + (serverinfo.userMsgNftyUrl ? serverinfo.userMsgNftyUrl : 'https://ntfy.sh/') + '" target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
15889
setDialogMode(2, "Messaging Notifications", 3, p30editMessagingEx, x, 'verifyMessaging');
15890
Q('d2handleinput').focus();
15891
if (userinfo.msghandle) {