- aggiornato sistema per inviare le newsletter !
This commit is contained in:
@@ -235,7 +235,7 @@ async function getDataNewsletter(lang, idapp) {
|
||||
|
||||
for (const user of arrml) {
|
||||
data.totemail++;
|
||||
if (user.statesub)
|
||||
if (user.news_on)
|
||||
data.totsubscribed++;
|
||||
else
|
||||
data.totunsubscribed++;
|
||||
@@ -284,6 +284,38 @@ router.post('/setactivate', authenticate, async (req, res) => {
|
||||
|
||||
});
|
||||
|
||||
router.post('/unsubscribe_user', async (req, res) => {
|
||||
hashemail = req.body.em;
|
||||
email = req.body.email;
|
||||
idapp = req.body.idapp;
|
||||
locale = req.body.locale ?? 'it';
|
||||
|
||||
try {
|
||||
const myuser = await User.findOne({ idapp, email }).lean();
|
||||
|
||||
if (myuser) {
|
||||
const hashcalc = tools.getHash(myuser.email + myuser.username);
|
||||
|
||||
if (hashcalc === hashemail) {
|
||||
await User.setNewsletter(idapp, myuser.username, false);
|
||||
|
||||
return res.send({
|
||||
code: server_constants.RIS_UNSUBSCRIBED_OK,
|
||||
msg: server_constants.RIS_SUBSCRIBED_MSG[locale]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
console.error('err', e);
|
||||
}
|
||||
res.send({
|
||||
code: server_constants.RIS_SUBSCRIBED_ERR
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
|
||||
router.post('/unsubscribe', (req, res) => {
|
||||
|
||||
console.log('unsubscribe -> ', req.body);
|
||||
|
||||
Reference in New Issue
Block a user