mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-09-11 08:55:32 +03:00
Improved event translation, #3516
This commit is contained in:
parent
0d457bb6e5
commit
9c0e3bd4c5
@ -30,7 +30,7 @@
|
||||
</area-disconnections>
|
||||
<area-footer>
|
||||
<p>
|
||||
To unsubscribe, <a href="[[[SERVERURL]]][[[UNSUBSCRIBELINK]]]">hier klicken</a> within 1 hour of getting this message.
|
||||
To unsubscribe, <a href="[[[SERVERURL]]][[[UNSUBSCRIBELINK]]]">hier klicken</a> innerhalb 1 Stunde nach erhalt dieser Nachricht.
|
||||
</p>
|
||||
</area-footer>
|
||||
</div></body></html>
|
25
meshuser.js
25
meshuser.js
@ -2097,18 +2097,20 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
if ((parent.GetMeshRights(user, mesh) & MESHRIGHT_EDITMESH) == 0) return;
|
||||
if ((command.meshid.split('/').length != 3) || (command.meshid.split('/')[1] != domain.id)) return; // Invalid domain, operation only valid for current domain
|
||||
|
||||
if ((common.validateString(command.meshname, 1, 128) == true) && (command.meshname != mesh.name)) { change = 'Group name changed from "' + mesh.name + '" to "' + command.meshname + '"'; mesh.name = command.meshname; }
|
||||
if ((common.validateString(command.desc, 0, 1024) == true) && (command.desc != mesh.desc)) { if (change != '') change += ' and description changed'; else change += 'Group "' + mesh.name + '" description changed'; mesh.desc = command.desc; }
|
||||
if ((common.validateInt(command.flags) == true) && (command.flags != mesh.flags)) { if (change != '') change += ' and flags changed'; else change += 'Group "' + mesh.name + '" flags changed'; mesh.flags = command.flags; }
|
||||
if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Group "' + mesh.name + '" consent changed'; mesh.consent = command.consent; }
|
||||
if ((common.validateInt(command.expireDevs, 0, 2000) == true) && (command.expireDevs != mesh.expireDevs)) { if (change != '') change += ' and auto-remove changed'; else change += 'Group "' + mesh.name + '" auto-remove changed'; if (command.expireDevs == 0) { delete mesh.expireDevs; } else { mesh.expireDevs = command.expireDevs; } }
|
||||
var changesids = [];
|
||||
if ((common.validateString(command.meshname, 1, 128) == true) && (command.meshname != mesh.name)) { change = 'Device group name changed from "' + mesh.name + '" to "' + command.meshname + '"'; changesids.push(1); mesh.name = command.meshname; }
|
||||
if ((common.validateString(command.desc, 0, 1024) == true) && (command.desc != mesh.desc)) { if (change != '') change += ' and description changed'; else change += 'Device group "' + mesh.name + '" description changed'; changesids.push(2); mesh.desc = command.desc; }
|
||||
if ((common.validateInt(command.flags) == true) && (command.flags != mesh.flags)) { if (change != '') change += ' and flags changed'; else change += 'Device group "' + mesh.name + '" flags changed'; changesids.push(3); mesh.flags = command.flags; }
|
||||
if ((common.validateInt(command.consent) == true) && (command.consent != mesh.consent)) { if (change != '') change += ' and consent changed'; else change += 'Device group "' + mesh.name + '" consent changed'; changesids.push(4); mesh.consent = command.consent; }
|
||||
if ((common.validateInt(command.expireDevs, 0, 2000) == true) && (command.expireDevs != mesh.expireDevs)) { if (change != '') change += ' and auto-remove changed'; else change += 'Device group "' + mesh.name + '" auto-remove changed'; changesids.push(5); if (command.expireDevs == 0) { delete mesh.expireDevs; } else { mesh.expireDevs = command.expireDevs; } }
|
||||
|
||||
// See if we need to change device group invitation codes
|
||||
if (mesh.mtype == 2) {
|
||||
if (command.invite === '*') {
|
||||
// Clear invite codes
|
||||
if (mesh.invite != null) { delete mesh.invite; }
|
||||
if (change != '') { change += ' and invite code changed'; } else { change += 'Group "' + mesh.name + '" invite code changed'; }
|
||||
if (change != '') { change += ' and invite code changed'; } else { change += 'Device group "' + mesh.name + '" invite code changed'; }
|
||||
changesids.push(6);
|
||||
} else if ((typeof command.invite == 'object') && (Array.isArray(command.invite.codes)) && (typeof command.invite.flags == 'number')) {
|
||||
// Set invite codes
|
||||
if ((mesh.invite == null) || (mesh.invite.codes != command.invite.codes) || (mesh.invite.flags != command.invite.flags)) {
|
||||
@ -2125,14 +2127,15 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
return;
|
||||
}
|
||||
mesh.invite = { codes: command.invite.codes, flags: command.invite.flags };
|
||||
if (change != '') { change += ' and invite code changed'; } else { change += 'Group "' + mesh.name + '" invite code changed'; }
|
||||
if (change != '') { change += ' and invite code changed'; } else { change += 'Device group "' + mesh.name + '" invite code changed'; }
|
||||
changesids.push(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (change != '') {
|
||||
db.Set(mesh);
|
||||
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, flags: mesh.flags, consent: mesh.consent, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id, invite: mesh.invite, expireDevs: command.expireDevs };
|
||||
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, name: mesh.name, mtype: mesh.mtype, desc: mesh.desc, flags: mesh.flags, consent: mesh.consent, action: 'meshchange', links: mesh.links, msgid: 142, msgArgs: [ mesh.name, changesids ], msg: change, domain: domain.id, invite: mesh.invite, expireDevs: command.expireDevs };
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
|
||||
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [user._id]), obj, event);
|
||||
}
|
||||
@ -2256,7 +2259,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
}
|
||||
|
||||
mesh = parent.meshes[command.meshid];
|
||||
change = '';
|
||||
if (mesh) {
|
||||
// Check if this user has rights to do this
|
||||
if ((parent.GetMeshRights(user, mesh) & MESHRIGHT_EDITMESH) == 0) return;
|
||||
@ -2265,7 +2267,6 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
// TODO: Check if this is a change from the existing policy
|
||||
|
||||
// Perform the Intel AMT policy change
|
||||
change = 'Intel AMT policy change';
|
||||
var amtpolicy = { type: command.amtpolicy.type };
|
||||
if ((command.amtpolicy.type === 2) || (command.amtpolicy.type === 3)) {
|
||||
amtpolicy = { type: command.amtpolicy.type, badpass: command.amtpolicy.badpass, cirasetup: command.amtpolicy.cirasetup };
|
||||
@ -2277,7 +2278,7 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
db.Set(mesh);
|
||||
var amtpolicy2 = Object.assign({}, amtpolicy); // Shallow clone
|
||||
if (amtpolicy2.password != null) { amtpolicy2.password = 1; }
|
||||
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, amt: amtpolicy2, action: 'meshchange', links: mesh.links, msg: change, domain: domain.id, invite: mesh.invite };
|
||||
var event = { etype: 'mesh', userid: user._id, username: user.name, meshid: mesh._id, amt: amtpolicy2, action: 'meshchange', links: mesh.links, msgid: 141, msg: "Intel(r) AMT policy change", domain: domain.id, invite: mesh.invite };
|
||||
if (db.changeStream) { event.noact = 1; } // If DB change stream is active, don't use this event to change the mesh. Another event will come.
|
||||
parent.parent.DispatchEvent(parent.CreateMeshDispatchTargets(mesh, [user._id]), obj, event);
|
||||
|
||||
@ -2963,6 +2964,8 @@ module.exports.CreateMeshUser = function (parent, db, ws, req, args, domain, use
|
||||
// Event the node change. Only do this if the database will not do it.
|
||||
event.msg = 'Changed device ' + node.name + ' from group ' + mesh.name + ': ' + changes.join(', ');
|
||||
event.node = parent.CloneSafeNode(node);
|
||||
event.msgid = 140;
|
||||
event.msgArgs = [ node.name, mesh.name, changes.join(', ') ];
|
||||
if (amtchange == 1) { event.amtchange = 1; } // This will give a hint to the AMT Manager to reconnect using new AMT credentials
|
||||
if (command.rdpport == 3389) { event.node.rdpport = 3389; }
|
||||
if (command.rfbport == 5900) { event.node.rfbport = 5900; }
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -13450,9 +13450,21 @@
|
||||
136: "Forcibly disconnected files session of user {0}",
|
||||
137: "Forcibly disconnected routing session of user {0}",
|
||||
138: "Added device share {0} recurring daily.",
|
||||
139: "Added device share {0} recurring weekly."
|
||||
139: "Added device share {0} recurring weekly.",
|
||||
140: "Changed device {0} from group {1}: {2}",
|
||||
141: "Intel(r) AMT policy change",
|
||||
142: "Device group {0} was changed: {1}"
|
||||
};
|
||||
|
||||
var eventsShortMessageId = {
|
||||
1: "Group name",
|
||||
2: "Description",
|
||||
3: "Flags",
|
||||
4: "Consent",
|
||||
5: "Auto-Remove",
|
||||
6: "Invite code"
|
||||
}
|
||||
|
||||
// Highlights the device being hovered
|
||||
function eventMouseHover(e, over) {
|
||||
e.children[1].classList.remove('g1s');
|
||||
@ -13486,7 +13498,14 @@
|
||||
if (event.msgArgs != null) {
|
||||
for (var i in event.msgArgs) {
|
||||
var xx = event.msgArgs[i];
|
||||
if (Array.isArray(xx)) {
|
||||
var x2 = [];
|
||||
for (var j in xx) { if ((typeof xx[j] == 'number') && (eventsShortMessageId[xx[j]])) { x2.push(eventsShortMessageId[xx[j]]); } else { x2.push(xx[j]); } }
|
||||
xx = x2.join(", ");
|
||||
} else {
|
||||
if ((typeof xx == 'string') && (xx.indexOf('DATETIME:') == 0)) { xx = printFlexDateTime(new Date(parseInt(xx.substring(9)))); }
|
||||
|
||||
}
|
||||
msg = msg.split('{' + i + '}').join(xx);
|
||||
}
|
||||
}
|
||||
|
@ -7628,7 +7628,7 @@ module.exports.CreateWebServer = function (parent, db, args, certificates, doneF
|
||||
if ((acceptLanguages[i] == 'en') || (acceptLanguages[i].startsWith('en-'))) {
|
||||
// English requested
|
||||
args.lang = 'en';
|
||||
if (user && (user.llang != 'en')) { user.llang = 'en'; obj.db.SetUser(user); } // Set user 'last language' used if needed.
|
||||
if (user && user.llang) { delete user.llang; obj.db.SetUser(user); } // Clear user 'last language' used if needed. Since English is the default, remove "last language".
|
||||
break;
|
||||
}
|
||||
if (fileOptions[acceptLanguages[i]] != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user