Added support device email notifications when user groups are used.

This commit is contained in:
Ylian Saint-Hilaire 2021-10-14 22:13:35 -07:00
parent 3815606eb7
commit 064540d865

View File

@ -2094,10 +2094,19 @@ function CreateMeshCentralServer(config, args) {
const mesh = obj.webserver.meshes[meshid];
if ((mesh == null) || (mesh.links == null)) return;
// Check if any user needs email notification
// TODO: Add user group support.
// Get the list of users that have visibility to this device
// This includes users that are part of user groups
var users = [];
for (var i in mesh.links) {
if (i.startsWith('user/')) {
if (i.startsWith('user/') && (users.indexOf(i) < 0)) { users.push(i); }
if (i.startsWith('ugrp/')) {
var usergrp = obj.webserver.userGroups[i];
if (usergrp.links != null) { for (var j in usergrp.links) { if (j.startsWith('user/') && (users.indexOf(j) < 0)) { users.push(j); } } }
}
}
// Check if any user needs email notification
for (var i in users) {
const user = obj.webserver.users[i];
if ((user != null) && (user.email != null) && (user.emailVerified == true)) {
var notify = 0;
@ -2131,7 +2140,6 @@ function CreateMeshCentralServer(config, args) {
}
}
}
}
// Set the connectivity state of a node and setup the server so that messages can be routed correctly.
// meshId: mesh identifier of format mesh/domain/meshidhex