Iscrizione Conacreis e Arcadei
This commit is contained in:
29
emails/iscrizione_arcadei/it/html.pug
Executable file
29
emails/iscrizione_arcadei/it/html.pug
Executable file
@@ -0,0 +1,29 @@
|
||||
p Ciao #{name},<br>Grazie per aver inviato la tua richiesta di adesione come Sostenitore di Arcadei !
|
||||
p Cordiali Saluti<br>Arcadei
|
||||
|
||||
style(type="text/css").
|
||||
html, body {
|
||||
padding: 0;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.divbtn {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.btn-lg {
|
||||
padding: 5px;
|
||||
margin: 5px;
|
||||
font-size: 26px;
|
||||
cursor: pointer;
|
||||
color: white;
|
||||
background: #027be3 !important;
|
||||
border-radius: 28px;
|
||||
|
||||
}
|
||||
1
emails/iscrizione_arcadei/it/subject.pug
Executable file
1
emails/iscrizione_arcadei/it/subject.pug
Executable file
@@ -0,0 +1 @@
|
||||
=`Richiesta di Adesione ad Arcadei (${name} ${surname})`
|
||||
@@ -5,40 +5,39 @@ require('./config/config');
|
||||
|
||||
const Email = require('email-templates');
|
||||
|
||||
const i18n = require("i18n");
|
||||
const i18n = require('i18n');
|
||||
|
||||
const { ObjectID } = require('mongodb');
|
||||
const { Settings } = require('./models/settings');
|
||||
const { TemplEmail } = require('./models/templemail');
|
||||
const { Discipline } = require('./models/discipline');
|
||||
const {ObjectID} = require('mongodb');
|
||||
const {Settings} = require('./models/settings');
|
||||
const {TemplEmail} = require('./models/templemail');
|
||||
const {Discipline} = require('./models/discipline');
|
||||
|
||||
const previewEmail = require('preview-email');
|
||||
const nodemailer = require("nodemailer");
|
||||
const nodemailer = require('nodemailer');
|
||||
|
||||
const OrdersCart = require('./models/orderscart');
|
||||
|
||||
const { MyEvent } = require('./models/myevent');
|
||||
const { MailingList } = require('./models/mailinglist');
|
||||
const { Newstosent } = require('./models/newstosent');
|
||||
const {MyEvent} = require('./models/myevent');
|
||||
const {MailingList} = require('./models/mailinglist');
|
||||
const {Newstosent} = require('./models/newstosent');
|
||||
|
||||
const server_constants = require('./tools/server_constants');
|
||||
|
||||
const shared_consts = require('./tools/shared_nodejs');
|
||||
|
||||
const { User } = require('./models/user');
|
||||
const {User} = require('./models/user');
|
||||
|
||||
const transport_preview = nodemailer.createTransport({
|
||||
jsonTransport: true
|
||||
jsonTransport: true,
|
||||
});
|
||||
|
||||
function checkifSendEmail() {
|
||||
return process.env.SEND_EMAIL === "1";
|
||||
return process.env.SEND_EMAIL === '1';
|
||||
//return false;
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
sendEmail_base_e_manager: function (idapp, template, to, mylocalsconf, replyTo, transport, previewonly) {
|
||||
sendEmail_base_e_manager: function(idapp, template, to, mylocalsconf, replyTo, transport, previewonly) {
|
||||
this.sendEmail_base(template, to, mylocalsconf, replyTo, transport, previewonly);
|
||||
|
||||
this.sendEmail_base(template, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '', transport, previewonly);
|
||||
@@ -50,10 +49,10 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendEmail_base: function (template, to, mylocalsconf, replyTo, transport, previewonly) {
|
||||
sendEmail_base: function(template, to, mylocalsconf, replyTo, transport, previewonly) {
|
||||
|
||||
if (to === '')
|
||||
return false
|
||||
return false;
|
||||
// console.log('mylocalsconf', mylocalsconf);
|
||||
|
||||
// console.log("check EMAIL :" + checkifSendEmail());
|
||||
@@ -65,8 +64,8 @@ module.exports = {
|
||||
message: {
|
||||
from: mylocalsconf.dataemail.from, // sender address
|
||||
headers: {
|
||||
'Reply-To': replyTo
|
||||
}
|
||||
'Reply-To': replyTo,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
@@ -111,25 +110,22 @@ module.exports = {
|
||||
|
||||
console.log(' *** Invia Email a ' + to, 'template', template);
|
||||
|
||||
return email
|
||||
.send({
|
||||
return email.send({
|
||||
template: template,
|
||||
message: {
|
||||
to: to,
|
||||
},
|
||||
locals: mylocalsconf,
|
||||
})
|
||||
.then((ris) => {
|
||||
}).then((ris) => {
|
||||
// console.log('ris EMAIL', ris);
|
||||
return !!ris
|
||||
})
|
||||
.catch((err) => {
|
||||
return !!ris;
|
||||
}).catch((err) => {
|
||||
console.error('sendEmail_base Error: ', err);
|
||||
return false
|
||||
return false;
|
||||
});
|
||||
},
|
||||
|
||||
sendEmail_Normale: async function (to, subject, html, replyTo) {
|
||||
sendEmail_Normale: async function(to, subject, html, replyTo) {
|
||||
|
||||
// setup e-mail data with unicode symbols
|
||||
var mailOptions = {
|
||||
@@ -141,24 +137,23 @@ module.exports = {
|
||||
html: html,
|
||||
};
|
||||
|
||||
|
||||
if (replyTo)
|
||||
mailOptions['reply-to'] = replyTo;
|
||||
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
if (process.env.SEND_EMAIL === "1") {
|
||||
if (process.env.SEND_EMAIL === '1') {
|
||||
// console.log("SEND EMAIL...");
|
||||
// send mail with defined transport object
|
||||
smtpTransport.sendMail(mailOptions, function (error, response) {
|
||||
smtpTransport.sendMail(mailOptions, function(error, response) {
|
||||
if (error) {
|
||||
console.log("Email Inviata ERRORE RISPOSTA: " + error);
|
||||
console.log('Email Inviata ERRORE RISPOSTA: ' + error);
|
||||
} else {
|
||||
// console.log("Email Inviata RISPOSTA: " + response);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
if (process.env.PROVA_EMAIL_TEMPLATE !== "1")
|
||||
if (process.env.PROVA_EMAIL_TEMPLATE !== '1')
|
||||
previewEmail(mailOptions).then(console.log).catch(console.error);
|
||||
else
|
||||
transport_preview.sendMail(mailOptions).then(console.log).catch(console.error);
|
||||
@@ -173,11 +168,11 @@ module.exports = {
|
||||
// }
|
||||
// },
|
||||
|
||||
getlinkReg: function (idapp, idreg) {
|
||||
getlinkReg: function(idapp, idreg) {
|
||||
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `?idapp=${idapp}&idlink=${idreg}`;
|
||||
return strlinkreg;
|
||||
},
|
||||
sendEmail_Registration: async function (lang, emailto, user, idapp, idreg) {
|
||||
sendEmail_Registration: async function(lang, emailto, user, idapp, idreg) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
@@ -205,7 +200,7 @@ module.exports = {
|
||||
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Push_Admin)) {
|
||||
const nometot = tools.getNomeCognomeEUserNameByUser(mylocalsconf);
|
||||
|
||||
let aportador = mylocalsconf.aportador_solidario ? ' (da ' + mylocalsconf.aportador_solidario + ')': '';
|
||||
let aportador = mylocalsconf.aportador_solidario ? ' (da ' + mylocalsconf.aportador_solidario + ')' : '';
|
||||
|
||||
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
|
||||
tools.sendNotifToAdmin('++ [' + numutenti + '] ' + nometot + aportador);
|
||||
@@ -215,7 +210,7 @@ module.exports = {
|
||||
// this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
// }
|
||||
},
|
||||
sendEmail_IscrizioneConacreis: async function (lang, emailto, iscritto, idapp) {
|
||||
sendEmail_IscrizioneConacreis: async function(lang, emailto, iscritto, idapp) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
@@ -228,7 +223,7 @@ module.exports = {
|
||||
emailto: emailto,
|
||||
iscritto,
|
||||
metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento),
|
||||
data_nascita: tools.getstrDate_DD_MM_YYYY(iscritto.dateofbirth)
|
||||
data_nascita: tools.getstrDate_DD_MM_YYYY(iscritto.dateofbirth),
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(iscritto, mylocalsconf);
|
||||
@@ -247,9 +242,10 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
sendEmail_IscrizioneArcadei: async function (lang, emailto, iscritto, idapp) {
|
||||
sendEmail_IscrizioneArcadei: async function(lang, emailto, iscritto, idapp) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
try {
|
||||
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
@@ -260,7 +256,7 @@ module.exports = {
|
||||
emailto: emailto,
|
||||
iscritto,
|
||||
metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento),
|
||||
data_nascita: tools.getstrDate_DD_MM_YYYY(iscritto.dateofbirth)
|
||||
data_nascita: tools.getstrDate_DD_MM_YYYY(iscritto.dateofbirth),
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(iscritto, mylocalsconf);
|
||||
@@ -277,9 +273,12 @@ module.exports = {
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('Err', e);
|
||||
}
|
||||
},
|
||||
|
||||
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot) {
|
||||
sendEmail_RequestNewPassword: async function(lang, user, emailto, idapp, tokenforgot) {
|
||||
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
@@ -295,12 +294,11 @@ module.exports = {
|
||||
this.sendEmail_base('resetpwd/' + lang, emailto, mylocalsconf, '');
|
||||
},
|
||||
|
||||
sendEmail_Booking: async function (res, lang, emailto, user, idapp, recbooking) {
|
||||
sendEmail_Booking: async function(res, lang, emailto, user, idapp, recbooking) {
|
||||
|
||||
tools.mylog('sendEmail_Booking');
|
||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||
|
||||
|
||||
let mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
@@ -318,8 +316,7 @@ module.exports = {
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
|
||||
return await Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING')
|
||||
.then(async (ris) => {
|
||||
return await Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING').then(async (ris) => {
|
||||
mylocalsconf.msgreply_after_booking = ris;
|
||||
|
||||
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Prenotazione');
|
||||
@@ -343,36 +340,38 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
preparaConfPerBooking: async function (res, idapp, mylocalsconf, recbooking, title) {
|
||||
preparaConfPerBooking: async function(res, idapp, mylocalsconf, recbooking, title) {
|
||||
|
||||
let texthtml = '';
|
||||
let msgtelegram = title + ' Evento [' + mylocalsconf.username + ' (' + mylocalsconf.name + ' ' + mylocalsconf.surname + ')] ' + mylocalsconf.eventtextplain;
|
||||
let msgtelegram = title + ' Evento [' + mylocalsconf.username + ' (' + mylocalsconf.name + ' ' + mylocalsconf.surname + ')] ' +
|
||||
mylocalsconf.eventtextplain;
|
||||
if (recbooking.modified) {
|
||||
msgtelegram += ' (modificato) '
|
||||
msgtelegram += ' (modificato) ';
|
||||
} else {
|
||||
msgtelegram += ' (Nuovo)'
|
||||
msgtelegram += ' (Nuovo)';
|
||||
}
|
||||
|
||||
msgtelegram += '\n';
|
||||
|
||||
if (recbooking.numpeople > 0) {
|
||||
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
|
||||
msgtelegram += mylocalsconf.participants + '\n'
|
||||
msgtelegram += mylocalsconf.participants + '\n';
|
||||
}
|
||||
|
||||
if (recbooking.numpeopleLunch > 0) {
|
||||
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
|
||||
msgtelegram += mylocalsconf.participantsLunch + '\n'
|
||||
msgtelegram += mylocalsconf.participantsLunch + '\n';
|
||||
}
|
||||
|
||||
if (recbooking.numpeopleDinner > 0) {
|
||||
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
|
||||
msgtelegram += mylocalsconf.participantsDinner + '\n'
|
||||
msgtelegram += mylocalsconf.participantsDinner + '\n';
|
||||
}
|
||||
|
||||
if (recbooking.numpeopleDinnerShared > 0) {
|
||||
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' + tools.getres__('partecipanti a Cena Condivisa', res);
|
||||
msgtelegram += mylocalsconf.participantsDinnerShared + '\n'
|
||||
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' +
|
||||
tools.getres__('partecipanti a Cena Condivisa', res);
|
||||
msgtelegram += mylocalsconf.participantsDinnerShared + '\n';
|
||||
}
|
||||
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
|
||||
@@ -381,7 +380,7 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendEmail_CancelBooking: async function (res, lang, emailto, user, idapp, recbooking) {
|
||||
sendEmail_CancelBooking: async function(res, lang, emailto, user, idapp, recbooking) {
|
||||
|
||||
tools.mylog('sendEmail_CancelBooking');
|
||||
|
||||
@@ -404,7 +403,8 @@ module.exports = {
|
||||
|
||||
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Cancellazione');
|
||||
|
||||
let msgtelegram = 'Cancellazione Evento [' + mylocalsconf.name + ' (' + mylocalsconf.name + ' ' + mylocalsconf.surname + ')] ' + mylocalsconf.eventtextplain;
|
||||
let msgtelegram = 'Cancellazione Evento [' + mylocalsconf.name + ' (' + mylocalsconf.name + ' ' + mylocalsconf.surname + ')] ' +
|
||||
mylocalsconf.eventtextplain;
|
||||
|
||||
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
|
||||
|
||||
@@ -418,7 +418,7 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
|
||||
sendEmail_Msg: async function (res, lang, emailto, user, idapp, recmsg) {
|
||||
sendEmail_Msg: async function(res, lang, emailto, user, idapp, recmsg) {
|
||||
|
||||
tools.mylog('sendEmail_Msg');
|
||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||
@@ -431,7 +431,7 @@ module.exports = {
|
||||
usernameorig: user.name + ' ' + user.surname,
|
||||
message: tools.convertTexttoHtml(recmsg.message),
|
||||
infoevent: recmsg.source.infoevent,
|
||||
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
||||
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id,
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
@@ -449,7 +449,7 @@ module.exports = {
|
||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
||||
},
|
||||
|
||||
sendEmail_ByText: async function (lang, emailto, user, idapp, rec) {
|
||||
sendEmail_ByText: async function(lang, emailto, user, idapp, rec) {
|
||||
|
||||
tools.mylog('sendEmail_ByText');
|
||||
|
||||
@@ -478,7 +478,7 @@ module.exports = {
|
||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
||||
},
|
||||
|
||||
sendEmail_ByNotif: async function (lang, emailto, user, idapp, recnotif) {
|
||||
sendEmail_ByNotif: async function(lang, emailto, user, idapp, recnotif) {
|
||||
|
||||
tools.mylog('sendEmail_ByNotif');
|
||||
|
||||
@@ -507,7 +507,7 @@ module.exports = {
|
||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
||||
},
|
||||
|
||||
Add_to_MailingList_AndSendEmailNotify: async function (lang, user, idapp, sendnews) {
|
||||
Add_to_MailingList_AndSendEmailNotify: async function(lang, user, idapp, sendnews) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
@@ -530,7 +530,7 @@ module.exports = {
|
||||
name: mylocalsconf.name,
|
||||
surname: mylocalsconf.surname,
|
||||
email: mylocalsconf.emailto,
|
||||
hash
|
||||
hash,
|
||||
});
|
||||
myperson._id = new ObjectID();
|
||||
} else {
|
||||
@@ -556,18 +556,18 @@ module.exports = {
|
||||
}
|
||||
}
|
||||
|
||||
return { code: server_constants.RIS_SUBSCRIBED_OK, msg: server_constants.RIS_SUBSCRIBED_MSG[lang] }
|
||||
return {code: server_constants.RIS_SUBSCRIBED_OK, msg: server_constants.RIS_SUBSCRIBED_MSG[lang]};
|
||||
} else {
|
||||
// Already Esist
|
||||
return {
|
||||
code: server_constants.RIS_SUBSCRIBED_ALREADYEXIST,
|
||||
msg: server_constants.RIS_SUBSCRIBED_MSG_ALREADYEXIST[lang]
|
||||
}
|
||||
msg: server_constants.RIS_SUBSCRIBED_MSG_ALREADYEXIST[lang],
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
Remove_from_MailingList: async function (lang, hashemail, idapp) {
|
||||
Remove_from_MailingList: async function(lang, hashemail, idapp) {
|
||||
|
||||
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
@@ -576,34 +576,35 @@ module.exports = {
|
||||
return {
|
||||
myperson: null,
|
||||
code: server_constants.RIS_UNSUBSCRIBED_ALREADY_DONE,
|
||||
msg: server_constants.RIS_UNSUBSCRIBED_MSG_ALREADY_DONE[lang]
|
||||
}
|
||||
msg: server_constants.RIS_UNSUBSCRIBED_MSG_ALREADY_DONE[lang],
|
||||
};
|
||||
}
|
||||
|
||||
const fields_to_update = {
|
||||
statesub: false
|
||||
statesub: false,
|
||||
};
|
||||
let myperson = await MailingList.findOneAndUpdate({
|
||||
idapp,
|
||||
hash: hashemail
|
||||
}, { $set: fields_to_update }, { new: false });
|
||||
hash: hashemail,
|
||||
}, {$set: fields_to_update}, {new: false});
|
||||
if (myperson) {
|
||||
return { myperson, code: server_constants.RIS_UNSUBSCRIBED_OK, msg: '' }
|
||||
return {myperson, code: server_constants.RIS_UNSUBSCRIBED_OK, msg: ''};
|
||||
|
||||
} else {
|
||||
// Not found !
|
||||
return {
|
||||
myperson: null,
|
||||
code: server_constants.RIS_UNSUBSCRIBED_NOT_EXIST,
|
||||
msg: server_constants.RIS_UNSUBSTR_NOT_EXIST[lang]
|
||||
}
|
||||
msg: server_constants.RIS_UNSUBSTR_NOT_EXIST[lang],
|
||||
};
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
fieldsloop: function (mylocalsconf, myvar) {
|
||||
fieldsloop: function(mylocalsconf, myvar) {
|
||||
const baseurl = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||
const urlunsibscribe = baseurl + '/unsubscribe?em=' + mylocalsconf.hashemail + '&mc=' + mylocalsconf.dataemail.mailchimpactive + '&email=' + mylocalsconf.emailto;
|
||||
const urlunsibscribe = baseurl + '/unsubscribe?em=' + mylocalsconf.hashemail + '&mc=' + mylocalsconf.dataemail.mailchimpactive +
|
||||
'&email=' + mylocalsconf.emailto;
|
||||
|
||||
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||
out = out.replace('{email}', mylocalsconf.emailto);
|
||||
@@ -612,20 +613,23 @@ module.exports = {
|
||||
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
||||
out = out.replace('{aportador_solidario}', mylocalsconf.aportador_solidario ? mylocalsconf.aportador_solidario : '');
|
||||
|
||||
return out
|
||||
return out;
|
||||
},
|
||||
|
||||
replacefields: function (mylocalsconf) {
|
||||
replacefields: function(mylocalsconf) {
|
||||
try {
|
||||
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer) : '';
|
||||
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom) : '';
|
||||
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf,
|
||||
mylocalsconf.dataemail.disclaimer) : '';
|
||||
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf,
|
||||
mylocalsconf.dataemail.disc_bottom) : '';
|
||||
if (mylocalsconf.dataemail.templ)
|
||||
mylocalsconf.dataemail.templ.testoheadermail_out = !!mylocalsconf.dataemail.templ.testoheadermail ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.templ.testoheadermail) : '';
|
||||
mylocalsconf.dataemail.templ.testoheadermail_out = !!mylocalsconf.dataemail.templ.testoheadermail ? this.fieldsloop(mylocalsconf,
|
||||
mylocalsconf.dataemail.templ.testoheadermail) : '';
|
||||
} catch (e) {
|
||||
console.error('Error replacefields: ' + e)
|
||||
console.error('Error replacefields: ' + e);
|
||||
}
|
||||
|
||||
return mylocalsconf
|
||||
return mylocalsconf;
|
||||
},
|
||||
|
||||
getdataemail: async (idapp) => {
|
||||
@@ -654,10 +658,10 @@ module.exports = {
|
||||
};
|
||||
|
||||
// console.log(mydata.templemail_id);
|
||||
mydata.templ = await TemplEmail.findOne({ _id: mydata.templemail_id });
|
||||
mydata.templ = await TemplEmail.findOne({_id: mydata.templemail_id});
|
||||
// console.log(mydata.templ);
|
||||
|
||||
return mydata
|
||||
return mydata;
|
||||
},
|
||||
|
||||
getTransport: (mylocalsconf) => {
|
||||
@@ -666,16 +670,17 @@ module.exports = {
|
||||
|
||||
// console.log('mylocalsconf.dataemail', mylocalsconf.dataemail);
|
||||
|
||||
if (mylocalsconf.dataemail.email_service !== 'gmail' && mylocalsconf.dataemail.email_service !== undefined && mylocalsconf.dataemail.email_service !== "") {
|
||||
if (mylocalsconf.dataemail.email_service !== 'gmail' && mylocalsconf.dataemail.email_service !== undefined &&
|
||||
mylocalsconf.dataemail.email_service !== '') {
|
||||
smtpTransport = nodemailer.createTransport({
|
||||
host: mylocalsconf.dataemail.email_service,
|
||||
port: mylocalsconf.dataemail.email_port,
|
||||
secureConnection: true,
|
||||
tls: { cipher: 'SSLv3' },
|
||||
tls: {cipher: 'SSLv3'},
|
||||
auth: {
|
||||
user: mylocalsconf.dataemail.from,
|
||||
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from)
|
||||
}
|
||||
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from),
|
||||
},
|
||||
});
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail' && !!mylocalsconf.dataemail.pwd_from) {
|
||||
|
||||
@@ -684,8 +689,8 @@ module.exports = {
|
||||
service: 'gmail', //'Gmail',
|
||||
auth: {
|
||||
user: mylocalsconf.dataemail.from,
|
||||
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from)
|
||||
}
|
||||
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from),
|
||||
},
|
||||
});
|
||||
} else {
|
||||
// smtpTransport = {
|
||||
@@ -693,8 +698,8 @@ module.exports = {
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||
}
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp),
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -703,7 +708,7 @@ module.exports = {
|
||||
return smtpTransport;
|
||||
},
|
||||
|
||||
setParamsForTemplate: function (user, mylocalsconf){
|
||||
setParamsForTemplate: function(user, mylocalsconf) {
|
||||
|
||||
try {
|
||||
mylocalsconf.username = user.username;
|
||||
@@ -715,14 +720,14 @@ module.exports = {
|
||||
mylocalsconf.user = user;
|
||||
|
||||
mylocalsconf = this.replacefields(mylocalsconf);
|
||||
}catch (e) {
|
||||
} catch (e) {
|
||||
console.error('setParamsForTemplate', e);
|
||||
}
|
||||
|
||||
return mylocalsconf;
|
||||
},
|
||||
|
||||
sendEmail_OrderProduct: async function (lang, idapp, orders, user) {
|
||||
sendEmail_OrderProduct: async function(lang, idapp, orders, user) {
|
||||
|
||||
const msginizio = 'Ordine n: ' + orders.numorder + ' ' + user.name + ' ' + user.surname;
|
||||
console.log(msginizio);
|
||||
@@ -737,15 +742,16 @@ module.exports = {
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
ordernumber: orders.numorder,
|
||||
user
|
||||
user,
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
|
||||
this.sendEmail_base_e_manager(idapp, 'ecommerce/makeorder/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply);
|
||||
this.sendEmail_base_e_manager(idapp, 'ecommerce/makeorder/' + lang, mylocalsconf.emailto, mylocalsconf,
|
||||
mylocalsconf.dataemail.email_reply);
|
||||
|
||||
},
|
||||
sendEmail_Order: async function (lang, idapp, orders, user, ordertype, status) {
|
||||
sendEmail_Order: async function(lang, idapp, orders, user, ordertype, status) {
|
||||
|
||||
const msginizio = 'INIZIO - sendEmail_Order ' + ordertype + ': ' + tools.getNomeAppByIdApp(idapp);
|
||||
console.log(msginizio);
|
||||
@@ -760,13 +766,14 @@ module.exports = {
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
ordernumber: orders.numorder,
|
||||
user
|
||||
user,
|
||||
};
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
|
||||
if ((status !== shared_consts.OrderStatus.CANCELED) && (status !== shared_consts.OrderStatus.RECEIVED)) {
|
||||
const esito = this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply);
|
||||
const esito = this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, mylocalsconf.emailto, mylocalsconf,
|
||||
mylocalsconf.dataemail.email_reply);
|
||||
|
||||
this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
@@ -777,7 +784,7 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
sendEmail_Newsletter_Events: async function (lang, idapp, id_newstosent) {
|
||||
sendEmail_Newsletter_Events: async function(lang, idapp, id_newstosent) {
|
||||
|
||||
const msginizio = 'INIZIO - sendEmail_Newsletter_Events: ' + tools.getNomeAppByIdApp(idapp);
|
||||
console.log(msginizio);
|
||||
@@ -795,12 +802,12 @@ module.exports = {
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
arrevents: myarrevents,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
dataemail: await this.getdataemail(idapp)
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
};
|
||||
|
||||
await Newstosent.processingJob(id_newstosent, true);
|
||||
|
||||
const mynewsrec = await Newstosent.findOne({ _id: id_newstosent });
|
||||
const mynewsrec = await Newstosent.findOne({_id: id_newstosent});
|
||||
|
||||
try {
|
||||
mynewsrec.numemail_tot = userstosend.length;
|
||||
@@ -829,7 +836,7 @@ module.exports = {
|
||||
await mynewsrec.save();
|
||||
await Newstosent.processingJob(id_newstosent, false);
|
||||
console.log('*** L\'Invio della Newsletter è stato fermato ! ');
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
|
||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||
@@ -843,7 +850,8 @@ module.exports = {
|
||||
|
||||
// Send Email to the User
|
||||
// console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
|
||||
const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, mylocalsconf.dataemail.email_reply, smtpTransport);
|
||||
const esito = this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf,
|
||||
mylocalsconf.dataemail.email_reply, smtpTransport);
|
||||
|
||||
if ((mynewsrec.numemail_sent % 100) === 0) {
|
||||
const msgproc = 'In Corso ' + mynewsrec.numemail_sent + ' / ' + mynewsrec.numemail_tot + ' Email inviate...';
|
||||
@@ -853,9 +861,8 @@ module.exports = {
|
||||
//Put the result in the database, to check if is sent or not.
|
||||
const updateml = await MailingList.findOneAndUpdate({
|
||||
idapp,
|
||||
email: user.email
|
||||
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
|
||||
|
||||
email: user.email,
|
||||
}, {$set: {lastid_newstosent: ObjectID(id_newstosent)}}, {new: false});
|
||||
|
||||
//Delay for send email...
|
||||
await tools.snooze(secpause);
|
||||
@@ -894,55 +901,50 @@ module.exports = {
|
||||
await mynewsrec.save();
|
||||
await Newstosent.processingJob(id_newstosent, false);
|
||||
console.log('*** L\'Invio della Newsletter è stato fermato ! ');
|
||||
return false
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
},
|
||||
|
||||
checkifSentNewsletter: async function (idapp) {
|
||||
checkifSentNewsletter: async function(idapp) {
|
||||
// Check if is the time to send the Newsletter
|
||||
|
||||
return await Newstosent.findNewsletter_To_Send(idapp)
|
||||
.then((rec) => {
|
||||
return await Newstosent.findNewsletter_To_Send(idapp).then((rec) => {
|
||||
if (rec)
|
||||
this.sendNewsletter(rec);
|
||||
});
|
||||
}
|
||||
,
|
||||
|
||||
checkifPendingNewsletter: async function (idapp) {
|
||||
checkifPendingNewsletter: async function(idapp) {
|
||||
// Check if is the time to send the Newsletter
|
||||
// Only newsletter pending en 8 hour last email sent.
|
||||
|
||||
return await Newstosent.findNewsletterPending_To_Send(idapp)
|
||||
.then((rec) => { //
|
||||
this.sendNewsletter(rec, idapp)
|
||||
return await Newstosent.findNewsletterPending_To_Send(idapp).then((rec) => { //
|
||||
this.sendNewsletter(rec, idapp);
|
||||
});
|
||||
},
|
||||
|
||||
sendNewsletter: async function (rec, idapp) {
|
||||
sendNewsletter: async function(rec, idapp) {
|
||||
if (rec) {
|
||||
// Start the job
|
||||
let myjobnews = await Newstosent.findOne({ _id: rec._id });
|
||||
let myjobnews = await Newstosent.findOne({_id: rec._id});
|
||||
if (!!myjobnews) {
|
||||
myjobnews.starting_job = true;
|
||||
myjobnews.datestartJob = new Date();
|
||||
|
||||
myjobnews.save()
|
||||
.then((ris) => {
|
||||
myjobnews.save().then((ris) => {
|
||||
|
||||
this.sendEmail_Newsletter_Events("it", idapp, rec._id);
|
||||
})
|
||||
.catch((e) => {
|
||||
this.sendEmail_Newsletter_Events('it', idapp, rec._id);
|
||||
}).catch((e) => {
|
||||
console.error(e.message);
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
testemail: async function (idapp, lang, previewonly) {
|
||||
testemail: async function(idapp, lang, previewonly) {
|
||||
|
||||
const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||
const myemail = await Settings.getValDbSettings(idapp, 'EMAIL_TEST');
|
||||
@@ -977,10 +979,9 @@ module.exports = {
|
||||
|
||||
},
|
||||
|
||||
testemailHtml: async function (idapp, lang, email, myuser) {
|
||||
testemailHtml: async function(idapp, lang, email, myuser) {
|
||||
|
||||
|
||||
let mytitle = 'Prova msg'
|
||||
let mytitle = 'Prova msg';
|
||||
let messaggio = '<br><b>Ciao!</b><div>Come stai?</div><br>Tutto Bene?<br><a href="https://ayni.gifteconomy.app/">Prova Link</a><br><i>Corsivo</i></i> ';
|
||||
|
||||
/*const htmlToText = require('html-to-text');
|
||||
@@ -994,11 +995,10 @@ module.exports = {
|
||||
|
||||
return await this.sendEmail_ByText(lang, email, myuser, idapp, {
|
||||
emailbody: messaggio,
|
||||
emailtitle: mytitle
|
||||
emailtitle: mytitle,
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
}
|
||||
;
|
||||
|
||||
@@ -3,10 +3,10 @@ const tools = require('../tools/general');
|
||||
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
||||
|
||||
const appTelegram_TEST = [tools.FREEPLANET, tools.ARCADEI, tools.RISO];
|
||||
const appTelegram_DEVELOP = [tools.RISO];
|
||||
const appTelegram_DEVELOP = [tools.RISO, tools.FREEPLANET];
|
||||
|
||||
const appTelegramFinti = ['2', tools.CNM];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
||||
const appTelegramFinti = ['2', tools.CNM, tools.ARCADEI];
|
||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET, tools.FREEPLANET];
|
||||
|
||||
const printf = require('util').format;
|
||||
|
||||
@@ -269,8 +269,8 @@ const Menu = {
|
||||
'Inv e NO 7 Req',
|
||||
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
||||
MSGPAOLO: emoji.get('incoming_envelope') + ' Invia a PAOLO',
|
||||
RESTART_SRV: emoji.get('incoming_envelope') + 'RestartServer',
|
||||
REBOOT_SRV: emoji.get('incoming_envelope') + 'RebootServer',
|
||||
RESTART_SRV: emoji.get('incoming_envelope') + 'Restart-NodeJs',
|
||||
REBOOT_SRV: emoji.get('incoming_envelope') + 'Reboot-VPS!',
|
||||
EXECSH: emoji.get('incoming_envelope') + 'ExecSH',
|
||||
LOG_SRV: '🖥Logserver.sh',
|
||||
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
|
||||
@@ -504,8 +504,8 @@ const txt = {
|
||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
||||
'🚫 Ci dispiace ma non sei stato Verificato correttamente dal tuo invitante %s.<br>Contattalo per farti abilitare !',
|
||||
MSG_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + '🚫 %s Non è stato Abilitato !',
|
||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%] Si è appena Iscritto al Conacreis "%s"',
|
||||
MSG_ISCRITTO_ARCADEI: emo.FIRE + '[%] Si è appena Iscritto ad Arcadei "%s"',
|
||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%s] Si è appena Iscritto al Conacreis "%s"',
|
||||
MSG_ISCRITTO_ARCADEI: emo.FIRE + '[%s] Si è appena Iscritto ad Arcadei "%s"',
|
||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
||||
@@ -813,7 +813,7 @@ const MyTelegramBot = {
|
||||
|
||||
let nomeapp = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||
|
||||
let text = printf(getstr(langdest, msg), nomeapp, NameFrom);
|
||||
let text = printf(getstr(langdest, msg), NameFrom, nomeapp);
|
||||
|
||||
let addtext = '';
|
||||
|
||||
|
||||
@@ -412,8 +412,8 @@ module.exports = {
|
||||
FREEPLANET: '1',
|
||||
AYNI: '7',
|
||||
CNM: '10',
|
||||
ARCADEI: '14',
|
||||
RISO: '13',
|
||||
ARCADEI: '15',
|
||||
|
||||
HELP_CHAT: '',
|
||||
TYPECONF_ZOOM: 'zoom',
|
||||
|
||||
Reference in New Issue
Block a user