From 7928f7fb3039e62ffde71867ec3153a72a305c50 Mon Sep 17 00:00:00 2001 From: si458 Date: Fri, 1 Nov 2024 11:23:45 +0000 Subject: [PATCH] fix ntfy missing user-agent #6488 Signed-off-by: si458 --- meshmessaging.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/meshmessaging.js b/meshmessaging.js index 47e1a6b4..646ae4a2 100644 --- a/meshmessaging.js +++ b/meshmessaging.js @@ -352,9 +352,9 @@ module.exports.CreateServer = function (parent) { 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 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 headers = (typeof parent.config.messaging.ntfy.authorization == 'string') ? { 'Authorization': parent.config.messaging.ntfy.authorization } : {}; - const req = require('https').request(new URL(url), { method: 'POST', headers: headers }, function (res) { if (func != null) { func(true); } }); - req.on('error', function (err) { if (func != null) { func(false); } }); + const headers = { 'User-Agent': 'MeshCentral v' + parent.currentVer }; + if (typeof parent.config.messaging.ntfy.authorization == 'string') { headers['Authorization'] = parent.config.messaging.ntfy.authorization; } + const req = require('https').request(new URL(url), { method: 'POST', headers: headers }, function (res) { if (func != null) { func(res.statusCode == 200); } }); req.end(msg); } else if ((to.startsWith('zulip:')) && (obj.zulipClient != null)) { // zulip obj.zulipClient.sendMessage({