correzione numseen, numfav, ...: ora li ho aggiunti alle tabelle...

This commit is contained in:
Surya Paolo
2023-10-01 01:24:47 +02:00
parent 142dcadca9
commit b6579832b6
27 changed files with 8952 additions and 8875 deletions

View File

@@ -8,35 +8,39 @@ const tools = require('../tools/general');
var server_constants = require('../tools/server_constants');
var {authenticate, auth_default} = require('../middleware/authenticate');
var { authenticate, authenticate_noerror, auth_default } = require('../middleware/authenticate');
var mongoose = require('mongoose').set('debug', false);
const Subscription = mongoose.model('subscribers');
const _ = require('lodash');
const {MyBacheca} = require('../models/mybacheca');
var {User} = require('../models/user');
const { MyBacheca } = require('../models/mybacheca');
var { User } = require('../models/user');
const { Reaction } = require('../models/reaction');
const globalTables = require('../tools/globalTables');
const {ObjectID} = require('mongodb');
const { ObjectID } = require('mongodb');
//GET orders
router.post('/page', authenticate, function(req, res, next) {
router.post('/page', authenticate_noerror, function (req, res, next) {
const {SendNotif} = require('../models/sendnotif');
const { SendNotif } = require('../models/sendnotif');
try {
let table = req.body.table;
let id = req.body.id;
let idapp = req.body.idapp;
const username = req.user.username ? req.user.username : '';
let username = ''
if (req.user)
username = req.user.username ? req.user.username : '';
// Check if ìs a Notif to read
const idnotif = req.body.idnotif ? req.body.idnotif : '';
SendNotif.setNotifAsRead(idapp, username, idnotif);
if (username) {
// Check if ìs a Notif to read
const idnotif = req.body.idnotif ? req.body.idnotif : '';
SendNotif.setNotifAsRead(idapp, username, idnotif);
}
let mytable = null;
if (shared_consts.TABLES_ENABLE_GETREC_BYID.includes(table)) {
@@ -47,29 +51,30 @@ router.post('/page', authenticate, function(req, res, next) {
if (mytable) {
return mytable.getMyRecById(idapp, id).
then(async (ris) => {
then(async (ris) => {
// Se è un record singolo di tipo Reaction,
// allora gli devo passare anche le liste degli utenti :
/*if (globalTables.isTableReaction(table)) {
// ...
const myreaction = await Reaction.find({idapp, idrec: id}).lean();
ris.myreaction = myreaction;
};*/
// Se è un record singolo di tipo Reaction,
// allora gli devo passare anche le liste degli utenti :
if (globalTables.isTableReaction(table)) {
// ...
// const myreaction = await Reaction.find({idapp, idrec: id}).lean();
// ris.myreaction = myreaction;
if (ris) {
res.send(ris);
};
} else {
res.status(400).send();
}
}).catch((e) => {
console.error('Err', e);
res.status(400).send(e);
})
if (ris) {
res.send(ris);
} else {
res.status(400).send();
}
}).catch((e) => {
console.error('Err', e);
res.status(400).send(e);
})
}
}catch (e) {
} catch (e) {
console.error('/page', e);
}