fix ntfy missing user-agent #6488

Signed-off-by: si458 <simonsmith5521@gmail.com>

si458 committed Nov 1, 2024 at 11:23 UTC 7928f7fb3039e62ffde71867ec3153a72a305c50
1 file changed +3 -3
meshmessaging.js
+3 -3
@@ -352,9 +352,9 @@ module.exports.CreateServer = function (parent) {
352 push.send(domain.title ? domain.title : 'MeshCentral', msg, function (err, res) { if (func != null) { func(err == null); } });
353 } else if ((to.startsWith('ntfy:')) && (obj.ntfyClient != null)) { // ntfy
354 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));
355 - const headers = (typeof parent.config.messaging.ntfy.authorization == 'string') ? { 'Authorization': parent.config.messaging.ntfy.authorization } : {};
356 - const req = require('https').request(new URL(url), { method: 'POST', headers: headers }, function (res) { if (func != null) { func(true); } });
357 - req.on('error', function (err) { if (func != null) { func(false); } });
355 + const headers = { 'User-Agent': 'MeshCentral v' + parent.currentVer };
356 + if (typeof parent.config.messaging.ntfy.authorization == 'string') { headers['Authorization'] = parent.config.messaging.ntfy.authorization; }
357 + const req = require('https').request(new URL(url), { method: 'POST', headers: headers }, function (res) { if (func != null) { func(res.statusCode == 200); } });
358 req.end(msg);
359 } else if ((to.startsWith('zulip:')) && (obj.zulipClient != null)) { // zulip
360 obj.zulipClient.sendMessage({