- check updates

- risolto problema della generazione dei PDF, avevo modificato in CMyPageElem , se si cambia qualcosa occorre stare attenti a mettere !hideHeader
This commit is contained in:
Surya Paolo
2025-11-01 12:00:57 +01:00
parent 38c13eef28
commit 8d1dd45648
26 changed files with 660 additions and 556 deletions

View File

@@ -746,7 +746,7 @@ router.post('/gettable', authenticate_noerror, (req, res) => {
params.table = sanitizeHtml(params.table);
if (!shared_consts.TABLES_ENABLE_GETTABLE_FOR_NOT_LOGGED.includes(params.table) && !req.user) {
return res.status(req.code).send({});
return res.status(server_constants.RIS_CODE_HTTP_FORBIDDEN_PERMESSI).send({msgerr: 'Non hai i permessi per vedere questa pagina.'});
}
let idapp = req.user ? req.user.idapp : sanitizeHtml(params.idapp);
@@ -2078,7 +2078,7 @@ async function load(req, res, version = '0') {
crons: version >= 91 ? Cron.findAllIdApp() : Promise.resolve([]),
raccoltacataloghis: version >= 91 ? RaccoltaCataloghi.findAllIdApp(idapp) : Promise.resolve([]),
myuserextra: req.user ? User.addExtraInfo(idapp, req.user, version) : Promise.resolve(null),
statuscode2: version >= 91 ? req.statuscode2 : Promise.resolve([]),
statuscode2: version >= 91 ? req.statuscode2 : Promise.resolve([]),
};
// Esecuzione parallela di tutte le promesse
@@ -2206,85 +2206,95 @@ async function load(req, res, version = '0') {
}
router.get(process.env.LINK_CHECK_UPDATES, authenticate_noerror, async (req, res) => {
const idapp = req.query.idapp;
try {
const idapp = req.query.idapp;
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
if (!req.user) {
return res.status(req.code).send();
}
// console.log("POST " + process.env.LINK_CHECK_UPDATES + " userId=" + userId);
if (!req.user) {
if (req.code === 1) return res.status(200).send();
else return res.status(req.code).send();
}
await CfgServer.find({ idapp })
.then(async (arrcfgrec) => {
if (arrcfgrec.length === 0) {
if (User.isAdmin(req.user.perm)) {
// crea un nuovo record
const mycfgServer = new CfgServer();
mycfgServer.idapp = idapp;
mycfgServer.chiave = 'vers';
mycfgServer.userId = 'ALL';
mycfgServer.valore = await tools.getVersServer();
await CfgServer.find({ idapp })
.then(async (arrcfgrec) => {
if (arrcfgrec.length === 0) {
if (User.isAdmin(req.user.perm)) {
// crea un nuovo record
const mycfgServer = new CfgServer();
mycfgServer.idapp = idapp;
mycfgServer.chiave = 'vers';
mycfgServer.userId = 'ALL';
mycfgServer.valore = await tools.getVersServer();
mycfgServer.save();
mycfgServer.save();
arrcfgrec = await CfgServer.find({ idapp });
} else {
return res.status(404).send();
}
}
// ++Add to Log Stat ....
let last_msgs = null;
let last_notifs = null;
let last_notifcoins = null;
let usersList = null;
let last_notifcoins_inattesa = null;
// const sall = '0';
// msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
if (req.user) {
const userId = req.user._id;
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
// Se sono il Gestore, le ricevo tutte quante:
if (User.isAdmin(req.user.perm)) {
last_notifcoins_inattesa = SendNotif.findAllNotifCoinsAllIdAndIdApp(idapp);
} else {
last_notifcoins_inattesa = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 200, true);
}
last_notifcoins = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 1, false);
if (req.user) {
// If User is Admin, then send user Lists
if (User.isAdmin(req.user.perm) || User.isEditor(req.user.perm) || User.isManager(req.user.perm)) {
// Send UsersList
usersList = User.getUsersList(idapp);
// usersList = null;
arrcfgrec = await CfgServer.find({ idapp });
} else {
return res.status(404).send();
}
}
}
return Promise.all([usersList, last_msgs, last_notifs, last_notifcoins, last_notifcoins_inattesa]).then(
(arrdata) => {
// console.table(arrdata);
return res.send({
CfgServer: arrcfgrec,
usersList: arrdata[0],
last_msgs: arrdata[1],
last_notifs: arrdata[2],
last_notifcoins: [...arrdata[4], ...arrdata[3]],
});
// ++Add to Log Stat ....
let last_msgs = null;
let last_notifs = null;
let last_notifcoins = null;
let usersList = null;
let last_notifcoins_inattesa = null;
// const sall = '0';
// msgs = SendMsg.findAllByUserIdAndIdApp(userId, req.user.username, req.user.idapp);
if (req.user) {
const userId = req.user._id;
if (!ObjectId.isValid(userId)) {
return res.status(404).send();
}
last_msgs = SendMsg.findLastGroupByUserIdAndIdApp(userId, req.user.username, idapp);
last_notifs = SendNotif.findLastNotifsByUserIdAndIdApp(req.user.username, idapp, 40);
// Se sono il Gestore, le ricevo tutte quante:
if (User.isAdmin(req.user.perm)) {
last_notifcoins_inattesa = SendNotif.findAllNotifCoinsAllIdAndIdApp(idapp);
} else {
last_notifcoins_inattesa = SendNotif.findLastNotifCoinsByUserIdAndIdApp(
req.user.username,
idapp,
200,
true
);
}
last_notifcoins = SendNotif.findLastNotifCoinsByUserIdAndIdApp(req.user.username, idapp, 1, false);
if (req.user) {
// If User is Admin, then send user Lists
if (User.isAdmin(req.user.perm) || User.isEditor(req.user.perm) || User.isManager(req.user.perm)) {
// Send UsersList
usersList = User.getUsersList(idapp);
// usersList = null;
}
}
}
);
})
.catch((e) => {
console.log(e.message);
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
});
return Promise.all([usersList, last_msgs, last_notifs, last_notifcoins, last_notifcoins_inattesa]).then(
(arrdata) => {
// console.table(arrdata);
return res.send({
CfgServer: arrcfgrec,
usersList: arrdata[0],
last_msgs: arrdata[1],
last_notifs: arrdata[2],
last_notifcoins: [...arrdata[4], ...arrdata[3]],
});
}
);
})
.catch((e) => {
console.log(e.message);
res.status(400).send({ code: server_constants.RIS_CODE_ERR, msg: e });
});
} catch (e) {
console.error('error:', e);
}
});
router.post('/upload_from_other_server/:dir', authenticate, (req, res) => {