mirror of
				https://github.com/Ylianst/MeshCentral.git
				synced 2025-03-09 15:40:18 +00:00 
			
		
		
		
	Added initial last seen handler function
This commit is contained in:
		
							parent
							
								
									da8947d25e
								
							
						
					
					
						commit
						18c367040d
					
				
					 1 changed files with 27 additions and 0 deletions
				
			
		
							
								
								
									
										27
									
								
								meshuser.js
									
										
									
									
									
								
							
							
						
						
									
										27
									
								
								meshuser.js
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -5404,6 +5404,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
 | 
			
		|||
        'getnetworkinfo': serverCommandGetNetworkInfo,
 | 
			
		||||
        'getsysinfo': serverCommandGetSysInfo,
 | 
			
		||||
        'lastconnect': serverCommandLastConnect,
 | 
			
		||||
        'lastseen': serverCommandLastSeen,
 | 
			
		||||
        'meshes': serverCommandMeshes,
 | 
			
		||||
        'serverconsole': serverCommandServerConsole,
 | 
			
		||||
        '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) {
 | 
			
		||||
        // 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) { }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue