Notifiche - Tutti - non letti

This commit is contained in:
Paolo Arena
2022-07-21 00:21:03 +02:00
parent cbd65ccdbe
commit e9ce597027
10 changed files with 235 additions and 177 deletions

View File

@@ -15,6 +15,8 @@ const sendemail = require('../sendemail');
const {Settings} = require('../models/settings');
const {SendNotif} = require('../models/sendnotif');
const tools = require('../tools/general');
const shared_consts = require('../tools/shared_nodejs');
@@ -377,11 +379,15 @@ router.patch('/:id', authenticate, (req, res) => {
router.post('/profile', authenticate, (req, res) => {
const username = req.body['username'];
idapp = req.body.idapp;
locale = req.body.locale;
const idapp = req.body.idapp;
const locale = req.body.locale;
const idnotif = req.body['idnotif'] ? req.body['idnotif'] : '';
//++Todo: controlla che tipo di dati ha il permesso di leggere
// Check if ìs a Notif to read
SendNotif.setNotifAsRead(idapp, username, idnotif);
try {
return User.getUserProfileByUsername(idapp, username, req.user.username,
false, req.user.perm).
@@ -447,7 +453,7 @@ router.post('/notifs', authenticate, async (req, res) => {
try {
if (!!myuser) {
if (notifs) {
if (tools.isArray(notifs) && notifs.length >= 0) {
myuser.profile.notifs = notifs;
myuser.save();
}