|
|
|
|
@@ -7,25 +7,25 @@ const Email = require('email-templates');
|
|
|
|
|
|
|
|
|
|
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 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 { MsgTemplate } = require('./models/msg_template');
|
|
|
|
|
|
|
|
|
|
@@ -39,7 +39,7 @@ function checkifSendEmail() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
@@ -51,7 +51,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendEmail_base: function(template, to, mylocalsconf, replyTo, transport, previewonly) {
|
|
|
|
|
sendEmail_base: function (template, to, mylocalsconf, replyTo, transport, previewonly) {
|
|
|
|
|
|
|
|
|
|
if (to === '')
|
|
|
|
|
return false;
|
|
|
|
|
@@ -127,7 +127,7 @@ module.exports = {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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 = {
|
|
|
|
|
@@ -147,7 +147,7 @@ module.exports = {
|
|
|
|
|
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);
|
|
|
|
|
} else {
|
|
|
|
|
@@ -162,52 +162,58 @@ 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));
|
|
|
|
|
try {
|
|
|
|
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
|
|
|
|
|
|
|
|
|
// ++ estrai l'html da mettere sulla email:
|
|
|
|
|
// const msghtml = await MsgTemplate.getMsgByLang(idapp, user, shared_consts.TypeMsgTemplate.MSG_BENV_REGISTRATO, user.lang);
|
|
|
|
|
// ++ estrai l'html da mettere sulla email:
|
|
|
|
|
// const msghtml = await MsgTemplate.getMsgByLang(idapp, user, shared_consts.TypeMsgTemplate.MSG_BENV_REGISTRATO, user.lang);
|
|
|
|
|
|
|
|
|
|
let mylocalsconf = {
|
|
|
|
|
idapp,
|
|
|
|
|
dataemail: await this.getdataemail(idapp),
|
|
|
|
|
locale: lang,
|
|
|
|
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
|
|
|
|
strlinksito: tools.getHostByIdApp(idapp),
|
|
|
|
|
strlinkreg: this.getlinkReg(idapp, idreg),
|
|
|
|
|
forgetpwd: tools.getHostByIdApp(idapp) + '/requestresetpwd',
|
|
|
|
|
emailto: emailto,
|
|
|
|
|
user,
|
|
|
|
|
};
|
|
|
|
|
let mylocalsconf = {
|
|
|
|
|
idapp,
|
|
|
|
|
dataemail: await this.getdataemail(idapp),
|
|
|
|
|
locale: lang,
|
|
|
|
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
|
|
|
|
strlinksito: tools.getHostByIdApp(idapp),
|
|
|
|
|
strlinkreg: this.getlinkReg(idapp, idreg),
|
|
|
|
|
forgetpwd: tools.getHostByIdApp(idapp) + '/requestresetpwd',
|
|
|
|
|
emailto: emailto,
|
|
|
|
|
user,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
|
|
|
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
|
|
|
|
|
|
|
|
|
this.sendEmail_base(tools.getpathregByIdApp(idapp, lang), emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
|
|
|
|
this.sendEmail_base(tools.getpathregByIdApp(idapp, lang), emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
|
|
|
|
|
|
|
|
|
// Send to the Admin an Email
|
|
|
|
|
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
|
|
|
|
// Send to the Admin an Email
|
|
|
|
|
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
|
|
|
|
|
|
|
|
|
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
|
|
|
|
|
await telegrambot.notifyToTelegram(telegrambot.phase.REGISTRATION, mylocalsconf);
|
|
|
|
|
|
|
|
|
|
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Push_Admin)) {
|
|
|
|
|
const nometot = tools.getNomeCognomeEUserNameByUser(mylocalsconf);
|
|
|
|
|
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(mylocalsconf.idapp, true, '++Reg [' + numutenti + '] ' + nometot + aportador);
|
|
|
|
|
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
|
|
|
|
|
tools.sendNotifToAdmin(mylocalsconf.idapp, true, '++Reg [' + numutenti + '] ' + nometot + aportador);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Err sendEmail_Registration', e);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// if (tools.isManagAndAdminDifferent(idapp)) {
|
|
|
|
|
// 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));
|
|
|
|
|
|
|
|
|
|
@@ -239,7 +245,7 @@ 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 {
|
|
|
|
|
@@ -275,7 +281,7 @@ module.exports = {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendEmail_RequestNewPassword: async function(lang, user, emailto, idapp, tokenforgot, tokenforgot_code) {
|
|
|
|
|
sendEmail_RequestNewPassword: async function (lang, user, emailto, idapp, tokenforgot, tokenforgot_code) {
|
|
|
|
|
console.log('sendEmail_RequestNewPassword');
|
|
|
|
|
|
|
|
|
|
let mylocalsconf = {
|
|
|
|
|
@@ -293,7 +299,7 @@ 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);
|
|
|
|
|
@@ -340,11 +346,11 @@ 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;
|
|
|
|
|
mylocalsconf.eventtextplain;
|
|
|
|
|
if (recbooking.modified) {
|
|
|
|
|
msgtelegram += ' (modificato) ';
|
|
|
|
|
} else {
|
|
|
|
|
@@ -374,7 +380,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
if (recbooking.numpeopleDinnerShared > 0) {
|
|
|
|
|
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' +
|
|
|
|
|
tools.getres__('partecipanti a Cena Condivisa', res);
|
|
|
|
|
tools.getres__('partecipanti a Cena Condivisa', res);
|
|
|
|
|
msgtelegram += mylocalsconf.participantsDinnerShared + '\n';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -384,11 +390,11 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
getName: function(mylocalsconf) {
|
|
|
|
|
getName: function (mylocalsconf) {
|
|
|
|
|
return mylocalsconf.name ? (mylocalsconf.surname ? (mylocalsconf.name + ' ' + mylocalsconf.surname) : mylocalsconf.name) : mylocalsconf.username
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
sendEmail_CancelBooking: async function(res, lang, emailto, user, idapp, recbooking) {
|
|
|
|
|
sendEmail_CancelBooking: async function (res, lang, emailto, user, idapp, recbooking) {
|
|
|
|
|
|
|
|
|
|
tools.mylog('sendEmail_CancelBooking');
|
|
|
|
|
|
|
|
|
|
@@ -425,7 +431,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);
|
|
|
|
|
@@ -456,7 +462,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');
|
|
|
|
|
|
|
|
|
|
@@ -485,7 +491,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');
|
|
|
|
|
|
|
|
|
|
@@ -514,7 +520,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));
|
|
|
|
|
|
|
|
|
|
@@ -563,7 +569,7 @@ 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 {
|
|
|
|
|
@@ -574,7 +580,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
Remove_from_MailingList: async function(lang, hashemail, idapp) {
|
|
|
|
|
Remove_from_MailingList: async function (lang, hashemail, idapp) {
|
|
|
|
|
|
|
|
|
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
|
|
|
|
|
|
|
|
|
@@ -593,9 +599,9 @@ module.exports = {
|
|
|
|
|
let myperson = await MailingList.findOneAndUpdate({
|
|
|
|
|
idapp,
|
|
|
|
|
hash: hashemail,
|
|
|
|
|
}, {$set: fields_to_update}, {new: false});
|
|
|
|
|
}, { $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 !
|
|
|
|
|
@@ -608,10 +614,10 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
'&email=' + mylocalsconf.emailto;
|
|
|
|
|
|
|
|
|
|
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
|
|
|
|
out = out.replace('{email}', mylocalsconf.emailto);
|
|
|
|
|
@@ -623,15 +629,15 @@ module.exports = {
|
|
|
|
|
return out;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
replacefields: function(mylocalsconf) {
|
|
|
|
|
replacefields: function (mylocalsconf) {
|
|
|
|
|
try {
|
|
|
|
|
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf,
|
|
|
|
|
mylocalsconf.dataemail.disclaimer) : '';
|
|
|
|
|
mylocalsconf.dataemail.disclaimer) : '';
|
|
|
|
|
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf,
|
|
|
|
|
mylocalsconf.dataemail.disc_bottom) : '';
|
|
|
|
|
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) : '';
|
|
|
|
|
} catch (e) {
|
|
|
|
|
console.error('Error replacefields: ' + e);
|
|
|
|
|
}
|
|
|
|
|
@@ -665,7 +671,7 @@ 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;
|
|
|
|
|
@@ -678,12 +684,12 @@ module.exports = {
|
|
|
|
|
// console.log('mylocalsconf.dataemail', mylocalsconf.dataemail);
|
|
|
|
|
|
|
|
|
|
if (mylocalsconf.dataemail.email_service !== 'gmail' && mylocalsconf.dataemail.email_service !== undefined &&
|
|
|
|
|
mylocalsconf.dataemail.email_service !== '') {
|
|
|
|
|
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),
|
|
|
|
|
@@ -715,7 +721,7 @@ module.exports = {
|
|
|
|
|
return smtpTransport;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
setParamsForTemplate: function(user, mylocalsconf) {
|
|
|
|
|
setParamsForTemplate: function (user, mylocalsconf) {
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
mylocalsconf.username = user.username;
|
|
|
|
|
@@ -734,7 +740,7 @@ module.exports = {
|
|
|
|
|
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);
|
|
|
|
|
@@ -755,10 +761,10 @@ module.exports = {
|
|
|
|
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
|
|
|
|
|
|
|
|
|
this.sendEmail_base_e_manager(idapp, 'ecommerce/makeorder/' + lang, mylocalsconf.emailto, mylocalsconf,
|
|
|
|
|
mylocalsconf.dataemail.email_reply);
|
|
|
|
|
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);
|
|
|
|
|
@@ -780,7 +786,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
mylocalsconf.dataemail.email_reply);
|
|
|
|
|
|
|
|
|
|
this.sendEmail_base('ecommerce/' + ordertype + '/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
|
|
|
|
|
|
|
|
|
@@ -791,7 +797,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);
|
|
|
|
|
@@ -814,7 +820,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
@@ -858,7 +864,7 @@ 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);
|
|
|
|
|
mylocalsconf.dataemail.email_reply, smtpTransport);
|
|
|
|
|
|
|
|
|
|
if ((mynewsrec.numemail_sent % 100) === 0) {
|
|
|
|
|
const msgproc = 'In Corso ' + mynewsrec.numemail_sent + ' / ' + mynewsrec.numemail_tot + ' Email inviate...';
|
|
|
|
|
@@ -869,7 +875,7 @@ module.exports = {
|
|
|
|
|
const updateml = await MailingList.findOneAndUpdate({
|
|
|
|
|
idapp,
|
|
|
|
|
email: user.email,
|
|
|
|
|
}, {$set: {lastid_newstosent: ObjectID(id_newstosent)}}, {new: false});
|
|
|
|
|
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
|
|
|
|
|
|
|
|
|
|
//Delay for send email...
|
|
|
|
|
await tools.snooze(secpause);
|
|
|
|
|
@@ -914,7 +920,7 @@ module.exports = {
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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) => {
|
|
|
|
|
@@ -924,7 +930,7 @@ module.exports = {
|
|
|
|
|
}
|
|
|
|
|
,
|
|
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
|
|
@@ -933,10 +939,10 @@ module.exports = {
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
@@ -951,7 +957,7 @@ module.exports = {
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
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');
|
|
|
|
|
@@ -979,14 +985,14 @@ module.exports = {
|
|
|
|
|
const smtpTransport = this.getTransport(mylocalsconf);
|
|
|
|
|
|
|
|
|
|
console.log('-> Invio Email TEST a', mylocalsconf.emailto, 'previewonly',
|
|
|
|
|
previewonly);
|
|
|
|
|
previewonly);
|
|
|
|
|
return await this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto,
|
|
|
|
|
mylocalsconf, '', smtpTransport, previewonly);
|
|
|
|
|
mylocalsconf, '', smtpTransport, previewonly);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
testemailHtml: async function(idapp, lang, email, myuser) {
|
|
|
|
|
testemailHtml: async function (idapp, lang, email, myuser) {
|
|
|
|
|
|
|
|
|
|
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> ';
|
|
|
|
|
@@ -1008,4 +1014,4 @@ module.exports = {
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
;
|
|
|
|
|
;
|
|
|
|
|
|