modif sqendmail to manage change in askregistertemplate

This commit is contained in:
philc 2025-02-07 11:15:50 +01:00
parent 25a561d4ef
commit 4683216987

View File

@ -74,15 +74,49 @@ router.post(
checkHeaders,
isAuthenticated,
async (req, res) => {
const data = req.body.data;
data.emailsto = req.body.emails;
// add accessright restriction here
/*const data = req.body.data;
data.emailsto = { to: req.body.emails };
const pathtpl = `../${req.params.tribe}/template/${req.params.template}_${req.session.header.xlang}.js`;
const campain = { emailsto: [] };
const sendemail = await Notifications.manageemail(
data,
pathtpl,
req.params.tribe
);
res.status(sendemail.status).send(sendemail);
);*/
let sendret;
if (req.body.emailsto && req.body.emailsto.length > 0) {
const sendcampain = Notifications.manageeamil(
req.body.emailsto,
req.params.template,
tribe,
req.session.header.xlang,
1
);
sendret = sendcampain;
} else if (req.body.emails) {
// To delete when Bhavesh removed direct email to send requesting registration
const campain = {
emailsto: [
{
to: req.body.emails,
},
],
};
Object.keys(req.body).forEach(k=>{
const newk= (k=="Cc")?"cc":k;
campain.emailsto[0][newk]=req.body[k]
})
sendret = Notifications.manageemail(
campain,
req.params.template,
tribe,
req.session.header.xlang,
1
);
}
res.status(sendret.status).send(sendret);
}
);