db.changestream fix for #3135

Ylian Saint-Hilaire committed Sep 15, 2021 at 08:25 UTC dbd7209070cd393dfb184f77002f05e28b95f229
1 file changed +2 -2
db.js
+2 -2
@@ -202,7 +202,7 @@ module.exports.CreateDB = function (parent, func) {
202 // Notify user change
203 var targets = ['*', 'server-users', cuser._id];
204 var event = { etype: 'user', userid: cuser._id, username: cuser.name, action: 'accountchange', msgid: 86, msgArgs: [cuser.name], msg: 'Removed user device rights for ' + cuser.name, domain: node.domain, account: parent.webserver.CloneSafeUser(cuser) };
205 - if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
205 + if (obj.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the user. Another event will come.
206 parent.DispatchEvent(targets, obj, event);
207 }
208 }
@@ -214,7 +214,7 @@ module.exports.CreateDB = function (parent, func) {
214 if ((parent.webserver.meshes[node.meshid] != null) && (parent.webserver.meshes[node.meshid].name != null)) { meshname = parent.webserver.meshes[node.meshid].name; }
215 var event = { etype: 'node', action: 'removenode', nodeid: node._id, msgid: 87, msgArgs: [node.name, meshname], msg: 'Removed device ' + node.name + ' from device group ' + meshname, domain: node.domain };
216 // TODO: We can't use the changeStream for node delete because we will not know the meshid the device was in.
217 - //if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to remove the node. Another event will come.
217 + //if (obj.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to remove the node. Another event will come.
218 parent.DispatchEvent(parent.webserver.CreateNodeDispatchTargets(node.meshid, node._id), obj, event);
219 });
220 }