turnaround issue brevo emailing

This commit is contained in:
2024-07-18 09:34:26 +02:00
parent b240419705
commit 22333d7db9
3 changed files with 293 additions and 40 deletions

View File

@@ -44,13 +44,24 @@ router.get("/messages/:alias/:tribeId", (req, res) => {
/**
* @api {POST} adminapi/notifications/sendmail/:tribe/:template -Send personnalize emails
* @apiName Sendmail
* @apiDescription Send personnalize email with data from template store in ../../{tribe}/template/{template}.json
* @apiDescription Send personnalize email with data from template store in ../../{tribe}/template/{template}.json and smtp in conf global or in /itm/{tribe}.json that must have valid parameter emailcontact must be authorized by the smtp
* "emailcontact": "noreply@smatchit.io",
* "smtp": {
* "host": "smtp-relay.brevo.com",
* "port": 587,
* "secure": false,
* "auth": {
* "user": "xx",
* "pass": "yy"
* }
* }
* @apiGroup Notifications
*
* @apiParam {string} template
* @apiParam {string} tribe
* @apiBody {array} emails to send (array of valid email)
* @apiBody {object} Data to personnalize template
* @apiBody {object} data to personnalize template
*
* @apiSuccess {object} notif content
* @apiSuccessExample {json} Success-Response:
@@ -59,24 +70,19 @@ router.get("/messages/:alias/:tribeId", (req, res) => {
* bouture
*/
router.post(
"/sendmail/:tribe/:template/:await",
"/sendmail/:tribe/:template",
checkHeaders,
isAuthenticated,
(req, res) => {
const pathtpl = `../../${req.params.tribe}/${req.params.template}.js`;
if (fs.existsSync(pathtpl)) {
const sendemail = Notification.manageemail(req.body, pathtpl,req.params.tribe);
res.status(sendemail.status).send(sendemail);
} else {
res
.status(404)
.send({
status: 404,
ref: "Notification",
msg: "templatenotfound",
data: { pathtpl },
});
}
async (req, res) => {
const data = req.body.data;
data.emailsto = req.body.emails;
const pathtpl = `../../${req.params.tribe}/template/${req.params.template}_${req.session.header.xlang}.js`;
const sendemail = await Notifications.manageemail(
data,
pathtpl,
req.params.tribe
);
res.status(sendemail.status).send(sendemail);
}
);
@@ -99,14 +105,12 @@ router.post(
router.post("/registeranonymous", checkHeaders, (req, res) => {
//console.log("list registration ",req.body)
if (!req.body.typekey || !["email", "telephone"].includes(req.body.typekey)) {
return res
.status(406)
.json({
status: 406,
ref: "Notifications",
msg: "typekeyunknown",
data: { typekey: req.body.typekey },
});
return res.status(406).json({
status: 406,
ref: "Notifications",
msg: "typekeyunknown",
data: { typekey: req.body.typekey },
});
}
const key = req.body.contactpoint
? req.body.contactpoint