Fixed user array type in MeshCore.

This commit is contained in:
Ylian Saint-Hilaire 2020-11-02 09:47:02 -08:00
parent b87342b937
commit 7f2bcbc919
3 changed files with 3 additions and 3 deletions

View File

@ -3723,7 +3723,7 @@ function createMeshCore(agent) {
if (x != LastPeriodicServerUpdate) { LastPeriodicServerUpdate = x; mesh.SendCommand(meshCoreObj); }
}
function sortObjRec(o) { if (typeof o != 'object') return o; for (var i in o) { if (typeof o[i] == 'object') { o[i] = sortObjRec(o[i]); } } return sortObj(o); }
function sortObjRec(o) { if ((typeof o != 'object') || (Array.isArray(o))) return o; for (var i in o) { if (typeof o[i] == 'object') { o[i] = sortObjRec(o[i]); } } return sortObj(o); }
function sortObj(o) { return Object.keys(o).sort().reduce(function (result, key) { result[key] = o[key]; return result; }, {}); }
// Starting function

View File

@ -1466,7 +1466,7 @@ module.exports.CreateMeshAgent = function (parent, db, ws, req, args, domain) {
if ((command.av != null) && (JSON.stringify(device.av) != JSON.stringify(command.av))) { /*changes.push('AV status');*/ device.av = command.av; change = 1; log = 1; }
}
if ((command.users != null) && (device.users != command.users)) { device.users = command.users; change = 1; } // Don't save this to the db.
if ((command.users != null) && (Array.isArray(command.users)) && (device.users != command.users)) { device.users = command.users; change = 1; } // Don't save this to the db.
if ((mesh.mtype == 2) && (!args.wanonly)) {
// In WAN mode, the hostname of a computer is not important. Don't log hostname changes.
if (device.host != obj.remoteaddr) { device.host = obj.remoteaddr; change = 1; changes.push('host'); }

View File

@ -3895,7 +3895,7 @@
}
function getUserShortStr(node) {
if (node == null || node.users == null || node.users.length == 0) return '';
if (node == null || node.users == null || (!Array.isArray(node.users)) || node.users.length == 0) return '';
if (node.users.length > 1) { return '<span title="' + EscapeHtml(node.users.join(', ')) + '">' + nobreak(format("{0} users", node.users.length)) + '</span>'; }
var u = node.users[0], su = u, i = u.indexOf('\\');
if (i > 0) { su = u.substring(i + 1); }