change notification to managepush
This commit is contained in:
@@ -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);
|
||||
|
Reference in New Issue
Block a user