mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2024-11-26 07:57:56 +03:00
Added support device email notifications when user groups are used.
This commit is contained in:
parent
3815606eb7
commit
064540d865
@ -2094,38 +2094,46 @@ function CreateMeshCentralServer(config, args) {
|
|||||||
const mesh = obj.webserver.meshes[meshid];
|
const mesh = obj.webserver.meshes[meshid];
|
||||||
if ((mesh == null) || (mesh.links == null)) return;
|
if ((mesh == null) || (mesh.links == null)) return;
|
||||||
|
|
||||||
// Check if any user needs email notification
|
// Get the list of users that have visibility to this device
|
||||||
// TODO: Add user group support.
|
// This includes users that are part of user groups
|
||||||
|
var users = [];
|
||||||
for (var i in mesh.links) {
|
for (var i in mesh.links) {
|
||||||
if (i.startsWith('user/')) {
|
if (i.startsWith('user/') && (users.indexOf(i) < 0)) { users.push(i); }
|
||||||
const user = obj.webserver.users[i];
|
if (i.startsWith('ugrp/')) {
|
||||||
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
var usergrp = obj.webserver.userGroups[i];
|
||||||
var notify = 0;
|
if (usergrp.links != null) { for (var j in usergrp.links) { if (j.startsWith('user/') && (users.indexOf(j) < 0)) { users.push(j); } } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Device group notifications
|
// Check if any user needs email notification
|
||||||
const meshLinks = user.links[meshid];
|
for (var i in users) {
|
||||||
if ((meshLinks != null) && (meshLinks.notify != null)) { notify |= meshLinks.notify; }
|
const user = obj.webserver.users[i];
|
||||||
|
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
|
||||||
|
var notify = 0;
|
||||||
|
|
||||||
// User notifications
|
// Device group notifications
|
||||||
if (user.notify != null) {
|
const meshLinks = user.links[meshid];
|
||||||
if (user.notify[meshid] != null) { notify |= user.notify[meshid]; }
|
if ((meshLinks != null) && (meshLinks.notify != null)) { notify |= meshLinks.notify; }
|
||||||
if (user.notify[nodeid] != null) { notify |= user.notify[nodeid]; }
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((notify & 48) != 0) {
|
// User notifications
|
||||||
if (stateSet == true) {
|
if (user.notify != null) {
|
||||||
if ((notify & 16) != 0) {
|
if (user.notify[meshid] != null) { notify |= user.notify[meshid]; }
|
||||||
mailserver.notifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
if (user.notify[nodeid] != null) { notify |= user.notify[nodeid]; }
|
||||||
} else {
|
}
|
||||||
mailserver.cancelNotifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
|
||||||
}
|
if ((notify & 48) != 0) {
|
||||||
|
if (stateSet == true) {
|
||||||
|
if ((notify & 16) != 0) {
|
||||||
|
mailserver.notifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
|
} else {
|
||||||
|
mailserver.cancelNotifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
}
|
}
|
||||||
else if (stateSet == false) {
|
}
|
||||||
if ((notify & 32) != 0) {
|
else if (stateSet == false) {
|
||||||
mailserver.notifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
if ((notify & 32) != 0) {
|
||||||
} else {
|
mailserver.notifyDeviceDisconnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
mailserver.cancelNotifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
} else {
|
||||||
}
|
mailserver.cancelNotifyDeviceConnect(user, meshid, nodeid, connectTime, connectType, powerState, serverid, extraInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user