Aggiunto comune, + filtro regione e provincia

aggiunto Visibilità (da fare check)
This commit is contained in:
Paolo Arena
2022-09-18 20:17:24 +02:00
parent 9d072d4d0d
commit bcb276518f
12 changed files with 127 additions and 19 deletions

View File

@@ -1,4 +1,3 @@
const express = require('express');
const router = express.Router();
@@ -62,6 +61,28 @@ router.get('/setall/:username/:qualinotif/:idapp', authenticate, async (req, res
});
router.get('/set/:_id/:idapp', authenticate, async (req, res) => {
const _id = req.params._id;
const username_call = req.user.username;
try {
let query = {_id, dest: username_call, read: false};
const rec = await SendNotif.findOne(query);
if (rec) {
rec.read = true;
await rec.save();
return res.send(true);
}
res.send(false);
} catch (e) {
res.status(400).send(e);
}
});
router.get('/del/:username/:id/:idapp', authenticate, async (req, res) => {
const idapp = req.params.idapp;
@@ -123,14 +144,14 @@ router.get('/:username/:lastdataread/:idapp', authenticate, (req, res) => {
return res.status(404).send({code: server_constants.RIS_CODE_NOT_MY_USERNAME});
}
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp).then( async (arrnotif) => {
return SendNotif.findAllNotifByUsernameIdAndIdApp(username, lastdataread, idapp).then(async (arrnotif) => {
// const wait = new Promise((resolve, reject) => {
// setTimeout(() => {
//++Todo: Ottimizzare ! Non occorre inviare tutti questi dati !!! Solo per il Circuito ?!
const userprofile = await User.getExtraInfoByUsername(idapp, req.user.username);
return res.send({arrnotif, userprofile } );
return res.send({arrnotif, userprofile});
}).catch((e) => {
console.log(e.message);