From 608661495b54798a42ac896ed6c7b972409137b0 Mon Sep 17 00:00:00 2001 From: philc Date: Wed, 29 Jan 2025 12:36:52 +0100 Subject: [PATCH] change notification to managepush --- README.md | 7 ------- apxtri/models/Notifications.js | 23 ++++++++++++++++++++--- 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index de5f2b3..5d13917 100644 --- a/README.md +++ b/README.md @@ -106,13 +106,6 @@ Until the web interface allow it here are usefull process to: ``` cd .. && . setup.sh smatchit https://admin.smatchit.io https://gitea.ndda.fr/smatchit/smatchit 1234 ``` -To conf a new website -* Update in adminapi/objects/tribes/itm/tribename.json add domaine name in dns -* Create a folder in tribename/objects/wwws/itm/webname/src and /dist -* from adminapi/apxtri/setup/nginx.wwwscf create file tribename/nginx/website.tribename.townname.nation.name.conf -* add in tribename/objects/wwws/itm/websitename.json the localdb to send to front -* Then conf website test domain and use sudo certbot --nginx -d domainename to get ssl and access in https - If you want to contribute fixing bug, add new features in adminapi please push in your branch and send an email to support@need-data.com. diff --git a/apxtri/models/Notifications.js b/apxtri/models/Notifications.js index 573b13a..eaa0b67 100644 --- a/apxtri/models/Notifications.js +++ b/apxtri/models/Notifications.js @@ -209,8 +209,20 @@ Notifications.sendsms = async (data, tribeId) => { } */ }; - -Notifications.manageemail = async (data, templatename, tribe, lg,numberpersecond) => { +Notifications.managepush = async(data,templatename,tribe,lg)=>{ + /** + * TODO + * open templatename get tplemail.notif renderit with data and push it + * with tribe parameter + */ + return { + status: 200, + ref: "Wwws", + msg: "pushmsgTODO", + data: {tribe,templatename}, + }; +} +Notifications.manageemail = async (data, templatename, tribe, lg,numberpersecond=10) => { const sleep = (ms) => { return new Promise((resolve) => setTimeout(resolve, ms)); }; @@ -269,6 +281,8 @@ Notifications.manageemail = async (data, templatename, tribe, lg,numberpersecond if (!Checkjson.testformat(emailtosend.to, "email")) { results.fail.push({ to: emailtosend.to, err: ["errorformat"] }); } else { + emailtosend.templatename=templatename; + emailtosend.lg=lg emailtosend.subject = Mustache.render(tplemail.subject, email); emailtosend.html = Mustache.render(tplemail.html, email); emailtosend.text = Mustache.render(tplemail.text, email); @@ -286,10 +300,12 @@ Notifications.manageemail = async (data, templatename, tribe, lg,numberpersecond //console.log(emailtosend) sendit = await Notifications.sendmail(emailtosend, tribe); //const sendit={status:200} + //console.log(sendit) if (sendit.status == 200) { results.success.push(emailtosend.to); } else { results.fail.push({ tp: emailtosend.to, status: sendit.status }); + console.log(sendit) } if ((i + 1) % numberpersecond === 0) { console.log("Prochain lot attend 1 seconde"); @@ -308,6 +324,7 @@ Notifications.manageemail = async (data, templatename, tribe, lg,numberpersecond data: { emailsucces: results.success.length, emailfail: results.fail.length, + failsdetail:results.fail, timems: Date.now() - start, }, }; @@ -432,7 +449,7 @@ Notifications.sendmail = async (data, tribe) => { data.subject ); */ - //fs.outputFile(`../${tribe}/template/test.html`, data.html); + fs.outputFile(`../${tribe}/template/${data.templatename}_${data.lg}.html`, data.html); try { res = await transporter.sendMail(data);