Fix for MongoDB change stream exception (#4429)
This commit is contained in:
parent
af1e5f52ca
commit
0ce946bd90
32
db.js
32
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];
|
||||||
for (var i in mesh) { mmesh[i] = mesh[i]; }
|
if (mmesh != null) {
|
||||||
for (var i in mmesh) { if (mesh[i] == null) { delete mmesh[i]; } }
|
// Update an existing device group
|
||||||
|
for (var i in mesh) { mmesh[i] = mesh[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'); }
|
||||||
|
@ -3253,11 +3259,17 @@ module.exports.CreateDB = function (parent, func) {
|
||||||
if (parent.webserver == null) return;
|
if (parent.webserver == null) return;
|
||||||
common.unEscapeLinksFieldName(userChange.fullDocument);
|
common.unEscapeLinksFieldName(userChange.fullDocument);
|
||||||
const user = performTypedRecordDecrypt([userChange.fullDocument])[0];
|
const user = performTypedRecordDecrypt([userChange.fullDocument])[0];
|
||||||
|
|
||||||
// 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];
|
||||||
for (var i in user) { muser[i] = user[i]; }
|
if (muser != null) {
|
||||||
for (var i in muser) { if (user[i] == null) { delete muser[i]; } }
|
// Update an existing user
|
||||||
|
for (var i in user) { muser[i] = user[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];
|
||||||
for (var i in usergroup) { uusergroup[i] = usergroup[i]; }
|
if (uusergroup != null) {
|
||||||
for (var i in uusergroup) { if (usergroup[i] == null) { delete uusergroup[i]; } }
|
// Update an existing user group
|
||||||
|
for (var i in usergroup) { uusergroup[i] = usergroup[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