Fix for MongoDB change stream exception (#4429)
This commit is contained in:
parent
af1e5f52ca
commit
0ce946bd90
18
db.js
18
db.js
|
@ -3236,8 +3236,14 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
|
|
||||||
// Update the mesh object in memory
|
// Update the mesh object in memory
|
||||||
const mmesh = parent.webserver.meshes[mesh._id];
|
const mmesh = parent.webserver.meshes[mesh._id];
|
||||||
|
if (mmesh != null) {
|
||||||
|
// Update an existing device group
|
||||||
for (var i in mesh) { mmesh[i] = mesh[i]; }
|
for (var i in mesh) { mmesh[i] = mesh[i]; }
|
||||||
for (var i in mmesh) { if (mesh[i] == null) { delete mmesh[i]; } }
|
for (var i in mmesh) { if (mesh[i] == null) { delete mmesh[i]; } }
|
||||||
|
} else {
|
||||||
|
// Device group not present, create it.
|
||||||
|
parent.webserver.meshes[mesh._id] = mesh;
|
||||||
|
}
|
||||||
|
|
||||||
// Send the mesh update
|
// Send the mesh update
|
||||||
if (mesh.deleted) { mesh.action = 'deletemesh'; } else { mesh.action = (added ? 'createmesh' : 'meshchange'); }
|
if (mesh.deleted) { mesh.action = 'deletemesh'; } else { mesh.action = (added ? 'createmesh' : 'meshchange'); }
|
||||||
|
@ -3256,8 +3262,14 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
|
|
||||||
// Update the user object in memory
|
// Update the user object in memory
|
||||||
const muser = parent.webserver.users[user._id];
|
const muser = parent.webserver.users[user._id];
|
||||||
|
if (muser != null) {
|
||||||
|
// Update an existing user
|
||||||
for (var i in user) { muser[i] = user[i]; }
|
for (var i in user) { muser[i] = user[i]; }
|
||||||
for (var i in muser) { if (user[i] == null) { delete muser[i]; } }
|
for (var i in muser) { if (user[i] == null) { delete muser[i]; } }
|
||||||
|
} else {
|
||||||
|
// User not present, create it.
|
||||||
|
parent.webserver.users[user._id] = user;
|
||||||
|
}
|
||||||
|
|
||||||
// Send the user update
|
// Send the user update
|
||||||
var targets = ['*', 'server-users', user._id];
|
var targets = ['*', 'server-users', user._id];
|
||||||
|
@ -3273,8 +3285,14 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
|
|
||||||
// Update the user group object in memory
|
// Update the user group object in memory
|
||||||
const uusergroup = parent.webserver.userGroups[usergroup._id];
|
const uusergroup = parent.webserver.userGroups[usergroup._id];
|
||||||
|
if (uusergroup != null) {
|
||||||
|
// Update an existing user group
|
||||||
for (var i in usergroup) { uusergroup[i] = usergroup[i]; }
|
for (var i in usergroup) { uusergroup[i] = usergroup[i]; }
|
||||||
for (var i in uusergroup) { if (usergroup[i] == null) { delete uusergroup[i]; } }
|
for (var i in uusergroup) { if (usergroup[i] == null) { delete uusergroup[i]; } }
|
||||||
|
} else {
|
||||||
|
// Usergroup not present, create it.
|
||||||
|
parent.webserver.userGroups[usergroup._id] = usergroup;
|
||||||
|
}
|
||||||
|
|
||||||
// Send the user group update
|
// Send the user group update
|
||||||
usergroup.action = (added ? 'createusergroup' : 'usergroupchange');
|
usergroup.action = (added ? 'createusergroup' : 'usergroupchange');
|
||||||
|
|
Loading…
Reference in New Issue