Fixed empty notifications titles, #4155

This commit is contained in:
Ylian Saint-Hilaire 2022-06-23 11:43:47 -07:00
parent 1e368f52b3
commit af0ff09144
2 changed files with 11 additions and 3 deletions

View File

@ -2913,7 +2913,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
// Perform input validation
try {
if (common.validateStrArray(command.nodeids, 1, 256) == false) { err = "Invalid nodeids"; } // Check nodeids
else if (common.validateString(command.title, 1, 512) == false) { err = "Invalid title"; } // Check title
else if (common.validateString(command.msg, 1, 4096) == false) { err = "Invalid message"; } // Check message
else {
var nodeids = [];
@ -2928,6 +2927,12 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
break;
}
// Check the title, if needed, use a default one
if (common.validateString(command.title, 1, 512) == false) { delete command.title } // Check title
if ((command.title == null) && (typeof domain.notificationmessages == 'object') && (typeof domain.notificationmessages.title == 'string')) { command.title = domain.notificationmessages.title; }
if ((command.title == null) && (typeof domain.title == 'string')) { command.title = domain.title; }
if (command.title == null) { command.title = "MeshCentral"; }
for (i in command.nodeids) {
// Get the node and the rights for this node
parent.GetNodeWithRights(domain, user, command.nodeids[i], function (node, rights, visible) {

View File

@ -5551,6 +5551,7 @@
var op = Q('d2deviceop').value, title = Q('dp2notifyTitle').value, msg = Q('d2notifyMsg').value, chkNodeIds = getCheckedDevices();
if (msg.length == 0) return;
if (title == '') { title = decodeURIComponent('{{{extitle}}}'); }
if (title == '') { title = "MeshCentral"; }
if (op == 1) { // MessageBox
for (var i = 0; i < chkNodeIds.length; i++) { meshserver.send({ action: 'msg', type: 'messagebox', nodeid: chkNodeIds[i], title: title, msg: msg }); }
} else if (op == 2) { // Toast
@ -7599,10 +7600,12 @@
}
function deviceMessageFunctionEx() {
var title = decodeURIComponent('{{{extitle}}}');
if (title == '') { title = "MeshCentral"; }
if (currentNode.pmt == 1) {
meshserver.send({ action: 'pushmessage', nodeid: currentNode._id, title: decodeURIComponent('{{{extitle}}}'), msg: Q('d2devMessage').value });
meshserver.send({ action: 'pushmessage', nodeid: currentNode._id, title: title, msg: Q('d2devMessage').value });
} else {
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: decodeURIComponent('{{{extitle}}}'), msg: Q('d2devMessage').value });
meshserver.send({ action: 'msg', type: 'messagebox', nodeid: currentNode._id, title: title, msg: Q('d2devMessage').value });
}
}