From 46832169875523d9617f2955480608d97231fdfb Mon Sep 17 00:00:00 2001 From: philc Date: Fri, 7 Feb 2025 11:15:50 +0100 Subject: [PATCH] modif sqendmail to manage change in askregistertemplate --- apxtri/routes/notifications.js | 42 ++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/apxtri/routes/notifications.js b/apxtri/routes/notifications.js index 8aed015..1a9af99 100644 --- a/apxtri/routes/notifications.js +++ b/apxtri/routes/notifications.js @@ -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); } );