Notification New Group

This commit is contained in:
paoloar77
2022-07-28 23:27:51 +02:00
parent 7cda5dbb8b
commit 241e4255d4
9 changed files with 63 additions and 32 deletions

View File

@@ -327,21 +327,12 @@ router.post('/settable', authenticate, async (req, res) => {
}
// tools.mylog('rec', rec);
}).then((myrec) => {
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
// nuovo Record:
// aggiungi il creatore al gruppo stesso
return User.setGroupsCmd(mydata.idapp, req.user.username,
myrec.groupname,
shared_consts.GROUPSCMD.SETGROUP, true, req.user.username).then((ris) => {
return res.send(myrec);
});
}
}).then(async (myrec) => {
let setnotif = false;
let typedir = 0;
let typeid = 0;
let groupNameDest = '';
if (shared_consts.TABLES_ADV_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_BACHECA;
@@ -358,13 +349,25 @@ router.post('/settable', authenticate, async (req, res) => {
if (shared_consts.TABLES_GROUPS_NOTIFICATION.includes(params.table)) {
typedir = shared_consts.TypeNotifs.TYPEDIR_GROUPS;
typeid = shared_consts.TypeNotifs.ID_GROUP_NEW_REC;
groupNameDest = myrec ? myrec.groupname : '';
setnotif = true;
}
if (setnotif) {
SendNotif.createNewNotification(req, res, params.table, myrec, typedir, typeid);
await SendNotif.createNewNotification(req, res, {groupNameDest}, params.table, myrec, typedir, typeid);
}
if (params.table === shared_consts.TAB_MYGROUPS && isnewrec) {
// nuovo Record:
// aggiungi il creatore al gruppo stesso
return User.setGroupsCmd(mydata.idapp, req.user.username,
myrec.groupname,
shared_consts.GROUPSCMD.SETGROUP, true, req.user.username).then((ris) => {
return res.send(myrec);
});
}
return res.send(myrec);
}).catch((e) => {
console.error('settable', e.message);