mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-01-12 23:43:20 -05:00
Added initial last seen handler function
This commit is contained in:
parent
da8947d25e
commit
18c367040d
27
meshuser.js
27
meshuser.js
@ -5404,6 +5404,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
'getnetworkinfo': serverCommandGetNetworkInfo,
|
'getnetworkinfo': serverCommandGetNetworkInfo,
|
||||||
'getsysinfo': serverCommandGetSysInfo,
|
'getsysinfo': serverCommandGetSysInfo,
|
||||||
'lastconnect': serverCommandLastConnect,
|
'lastconnect': serverCommandLastConnect,
|
||||||
|
'lastseen': serverCommandLastSeen,
|
||||||
'meshes': serverCommandMeshes,
|
'meshes': serverCommandMeshes,
|
||||||
'serverconsole': serverCommandServerConsole,
|
'serverconsole': serverCommandServerConsole,
|
||||||
'servererrors': serverCommandServerErrors,
|
'servererrors': serverCommandServerErrors,
|
||||||
@ -5537,6 +5538,32 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function serverCommandLastSeen(command) {
|
||||||
|
var links = parent.GetAllMeshIdWithRights(user);
|
||||||
|
var extraids = getUserExtraIds();
|
||||||
|
db.GetAllTypeNoTypeFieldMeshFiltered(links, extraids, domain.id, 'node', null, (err, docs) => {
|
||||||
|
if (docs == null) { docs = []; }
|
||||||
|
|
||||||
|
// use associative array to join lastconnects on to users's nodes (left join)
|
||||||
|
var LCs = {}
|
||||||
|
for (var i in docs) {
|
||||||
|
LCs[docs[i]._id] = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
db.GetAllType('lastconnect', (err, docs) => {
|
||||||
|
for (var j in docs) {
|
||||||
|
var nodeid = docs[j]._id.substring(2);
|
||||||
|
if (LCs[nodeid] != null) {
|
||||||
|
delete docs[j]._id;
|
||||||
|
LCs[nodeid] = docs[j];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(LCs);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function serverCommandMeshes(command) {
|
function serverCommandMeshes(command) {
|
||||||
// Request a list of all meshes this user as rights to
|
// Request a list of all meshes this user as rights to
|
||||||
try { ws.send(JSON.stringify({ action: 'meshes', meshes: parent.GetAllMeshWithRights(user).map(parent.CloneSafeMesh), tag: command.tag })); } catch (ex) { }
|
try { ws.send(JSON.stringify({ action: 'meshes', meshes: parent.GetAllMeshWithRights(user).map(parent.CloneSafeMesh), tag: command.tag })); } catch (ex) { }
|
||||||
|
Loading…
Reference in New Issue
Block a user