mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	ntfy improvements.
This commit is contained in:
		
							parent
							
								
									8f84c5d2d3
								
							
						
					
					
						commit
						6b8acc1675
					
				
					 4 changed files with 46 additions and 3 deletions
				
			
		| 
						 | 
					@ -1379,6 +1379,44 @@
 | 
				
			||||||
            "token": { "type": "string", "description": "A Discord bot token that MeshCentral will use to login to Discord." }
 | 
					            "token": { "type": "string", "description": "A Discord bot token that MeshCentral will use to login to Discord." }
 | 
				
			||||||
          },
 | 
					          },
 | 
				
			||||||
          "required": [ "token" ]
 | 
					          "required": [ "token" ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "xmpp": {
 | 
				
			||||||
 | 
					          "type": "object",
 | 
				
			||||||
 | 
					          "description": "Configure XMPP messaging system",
 | 
				
			||||||
 | 
					          "properties": {
 | 
				
			||||||
 | 
					            "service": { "type": "string", "description": "Host name of the XMPP server." },
 | 
				
			||||||
 | 
					            "credentials": {
 | 
				
			||||||
 | 
					              "type": "object",
 | 
				
			||||||
 | 
					              "description": "Login credentials for the XMPP server.",
 | 
				
			||||||
 | 
					              "properties": {
 | 
				
			||||||
 | 
					                "username": { "type": "string" },
 | 
				
			||||||
 | 
					                "password": { "type": "string" }
 | 
				
			||||||
 | 
					              }
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          "required": [ "credentials" ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "callmebot": {
 | 
				
			||||||
 | 
					          "type": "boolean",
 | 
				
			||||||
 | 
					          "default": false,
 | 
				
			||||||
 | 
					          "description": "Enabled CallMeBot integration support."
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "pushover": {
 | 
				
			||||||
 | 
					          "type": "object",
 | 
				
			||||||
 | 
					          "description": "Configure Pushover messaging system",
 | 
				
			||||||
 | 
					          "properties": {
 | 
				
			||||||
 | 
					            "token": { "type": "string", "description": "A Pushover application token that MeshCentral will use to login." }
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          "required": [ "token" ]
 | 
				
			||||||
 | 
					        },
 | 
				
			||||||
 | 
					        "ntfy": {
 | 
				
			||||||
 | 
					          "type": [ "boolean", "object" ],
 | 
				
			||||||
 | 
					          "default": false,
 | 
				
			||||||
 | 
					          "properties": {
 | 
				
			||||||
 | 
					            "host": { "type": "string", "description": "Host name of the ntfy server." },
 | 
				
			||||||
 | 
					            "userurl": { "type": "string", "description": "A URL given to users to help them setup this service." }
 | 
				
			||||||
 | 
					          },
 | 
				
			||||||
 | 
					          "description": "Enabled ntfy.sh integration support."
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -292,7 +292,8 @@ module.exports.CreateServer = function (parent) {
 | 
				
			||||||
            const push = new Pushover({ token: parent.config.messaging.pushover.token, user: to.substring(9) });
 | 
					            const push = new Pushover({ token: parent.config.messaging.pushover.token, user: to.substring(9) });
 | 
				
			||||||
            push.send(domain.title ? domain.title : 'MeshCentral', msg, function (err, res) { if (func != null) { func(err == null); } });
 | 
					            push.send(domain.title ? domain.title : 'MeshCentral', msg, function (err, res) { if (func != null) { func(err == null); } });
 | 
				
			||||||
        } else if ((to.startsWith('ntfy:')) && (obj.ntfyClient != null)) { // ntfy
 | 
					        } else if ((to.startsWith('ntfy:')) && (obj.ntfyClient != null)) { // ntfy
 | 
				
			||||||
            const req = require('https').request(new URL('https://ntfy.sh/' + encodeURIComponent(to.substring(5))), { method: 'POST' }, function (res) { if (func != null) { func(true); } });
 | 
					            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));
 | 
				
			||||||
 | 
					            const req = require('https').request(new URL(url), { method: 'POST' }, function (res) { if (func != null) { func(true); } });
 | 
				
			||||||
            req.on('error', function (err) { if (func != null) { func(false); } });
 | 
					            req.on('error', function (err) { if (func != null) { func(false); } });
 | 
				
			||||||
            req.end(msg);
 | 
					            req.end(msg);
 | 
				
			||||||
        } else {
 | 
					        } else {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -579,6 +579,9 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
				
			||||||
                serverinfo.userMsgProviders = parent.parent.msgserver.providers;
 | 
					                serverinfo.userMsgProviders = parent.parent.msgserver.providers;
 | 
				
			||||||
                if (parent.parent.msgserver.discordUrl != null) { serverinfo.discordUrl = parent.parent.msgserver.discordUrl; }
 | 
					                if (parent.parent.msgserver.discordUrl != null) { serverinfo.discordUrl = parent.parent.msgserver.discordUrl; }
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 | 
					            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
 | 
				
			||||||
 | 
					                serverinfo.userMsgNftyUrl = parent.parent.config.messaging.ntfy.userurl;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            // Build the mobile agent URL, this is used to connect mobile devices
 | 
					            // Build the mobile agent URL, this is used to connect mobile devices
 | 
				
			||||||
            var agentServerName = parent.getWebServerName(domain, req);
 | 
					            var agentServerName = parent.getWebServerName(domain, req);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -11995,7 +11995,8 @@
 | 
				
			||||||
                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>'; }
 | 
					                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>'; }
 | 
				
			||||||
                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>';
 | 
					                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>';
 | 
				
			||||||
                x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
 | 
					                x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
 | 
				
			||||||
                x += '<div id=d2ntfyinfo style=display:none><br /><a href=https://ntfy.sh/ target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
 | 
					                console.log(serverinfo.userMsgNftyUrl);
 | 
				
			||||||
 | 
					                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>';
 | 
				
			||||||
                setDialogMode(2, "Messaging Notifications", 3, account_manageMessagingAdd, x, 'verifyMessaging');
 | 
					                setDialogMode(2, "Messaging Notifications", 3, account_manageMessagingAdd, x, 'verifyMessaging');
 | 
				
			||||||
                Q('d2handleinput').focus();
 | 
					                Q('d2handleinput').focus();
 | 
				
			||||||
                account_manageMessagingValidate();
 | 
					                account_manageMessagingValidate();
 | 
				
			||||||
| 
						 | 
					@ -15884,7 +15885,7 @@
 | 
				
			||||||
            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>' }
 | 
					            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>' }
 | 
				
			||||||
            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>';
 | 
					            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>';
 | 
				
			||||||
            x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
 | 
					            x += '<div id=d2pushoverinfo style=display:none><br /><a href=https://pushover.net/ target="_pushover">' + "Information at Pushover.net" + '</a></div>';
 | 
				
			||||||
            x += '<div id=d2ntfyinfo style=display:none><br /><a href=https://ntfy.sh/ target="_ntfy">' + "Free service at ntfy.sh" + '</a></div>';
 | 
					            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>';
 | 
				
			||||||
            setDialogMode(2, "Messaging Notifications", 3, p30editMessagingEx, x, 'verifyMessaging');
 | 
					            setDialogMode(2, "Messaging Notifications", 3, p30editMessagingEx, x, 'verifyMessaging');
 | 
				
			||||||
            Q('d2handleinput').focus();
 | 
					            Q('d2handleinput').focus();
 | 
				
			||||||
            if (userinfo.msghandle) {
 | 
					            if (userinfo.msghandle) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue