MongoDB change stream now updates memory objects.

This commit is contained in:
Ylian Saint-Hilaire 2019-05-31 11:38:35 -07:00
parent eb6396705d
commit 7529dce77b
2 changed files with 15 additions and 1 deletions

14
db.js
View File

@ -812,6 +812,13 @@ module.exports.CreateDB = function (parent, func) {
// Called when a device group has changed
function dbMeshChange(meshChange, added) {
const mesh = meshChange.fullDocument;
// Update the mesh object in memory
const mmesh = parent.webserver.meshes[mesh._id];
for (var i in mesh) { mmesh[i] = mesh[i]; }
for (var i in mmesh) { if (mesh[i] == null) { delete mmesh[i]; } }
// Send the mesh update
if (mesh.deleted) { mesh.action = 'deletemesh'; } else { mesh.action = (added ? 'createmesh' : 'meshchange'); }
mesh.meshid = mesh._id;
mesh.nolog = 1;
@ -823,6 +830,13 @@ module.exports.CreateDB = function (parent, func) {
// Called when a user account has changed
function dbUserChange(userChange, added) {
const user = userChange.fullDocument;
// Update the user object in memory
const muser = parent.webserver.users[user._id];
for (var i in user) { muser[i] = user[i]; }
for (var i in muser) { if (user[i] == null) { delete muser[i]; } }
// Send the user update
parent.DispatchEvent(['*', 'server-users', user._id], obj, { etype: 'user', username: user.name, account: parent.webserver.CloneSafeUser(user), action: (added ? 'accountcreate' : 'accountchange'), domain: user.domain, nolog: 1 });
}

View File

@ -1,6 +1,6 @@
{
"name": "meshcentral",
"version": "0.3.5-p",
"version": "0.3.5-r",
"keywords": [
"Remote Management",
"Intel AMT",