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 Email = require('email-templates');
|
||||||
|
|
||||||
const i18n = require("i18n");
|
const i18n = require('i18n');
|
||||||
|
|
||||||
const { ObjectID } = require('mongodb');
|
const {ObjectID} = require('mongodb');
|
||||||
const { Settings } = require('./models/settings');
|
const {Settings} = require('./models/settings');
|
||||||
const { TemplEmail } = require('./models/templemail');
|
const {TemplEmail} = require('./models/templemail');
|
||||||
const { Discipline } = require('./models/discipline');
|
const {Discipline} = require('./models/discipline');
|
||||||
|
|
||||||
const previewEmail = require('preview-email');
|
const previewEmail = require('preview-email');
|
||||||
const nodemailer = require("nodemailer");
|
const nodemailer = require('nodemailer');
|
||||||
|
|
||||||
const OrdersCart = require('./models/orderscart');
|
const OrdersCart = require('./models/orderscart');
|
||||||
|
|
||||||
const { MyEvent } = require('./models/myevent');
|
const {MyEvent} = require('./models/myevent');
|
||||||
const { MailingList } = require('./models/mailinglist');
|
const {MailingList} = require('./models/mailinglist');
|
||||||
const { Newstosent } = require('./models/newstosent');
|
const {Newstosent} = require('./models/newstosent');
|
||||||
|
|
||||||
const server_constants = require('./tools/server_constants');
|
const server_constants = require('./tools/server_constants');
|
||||||
|
|
||||||
const shared_consts = require('./tools/shared_nodejs');
|
const shared_consts = require('./tools/shared_nodejs');
|
||||||
|
|
||||||
const { User } = require('./models/user');
|
const {User} = require('./models/user');
|
||||||
|
|
||||||
const transport_preview = nodemailer.createTransport({
|
const transport_preview = nodemailer.createTransport({
|
||||||
jsonTransport: true
|
jsonTransport: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
function checkifSendEmail() {
|
function checkifSendEmail() {
|
||||||
return process.env.SEND_EMAIL === "1";
|
return process.env.SEND_EMAIL === '1';
|
||||||
//return false;
|
//return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = {
|
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, to, mylocalsconf, replyTo, transport, previewonly);
|
||||||
|
|
||||||
this.sendEmail_base(template, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '', 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 === '')
|
if (to === '')
|
||||||
return false
|
return false;
|
||||||
// console.log('mylocalsconf', mylocalsconf);
|
// console.log('mylocalsconf', mylocalsconf);
|
||||||
|
|
||||||
// console.log("check EMAIL :" + checkifSendEmail());
|
// console.log("check EMAIL :" + checkifSendEmail());
|
||||||
@@ -65,8 +64,8 @@ module.exports = {
|
|||||||
message: {
|
message: {
|
||||||
from: mylocalsconf.dataemail.from, // sender address
|
from: mylocalsconf.dataemail.from, // sender address
|
||||||
headers: {
|
headers: {
|
||||||
'Reply-To': replyTo
|
'Reply-To': replyTo,
|
||||||
}
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -111,25 +110,22 @@ module.exports = {
|
|||||||
|
|
||||||
console.log(' *** Invia Email a ' + to, 'template', template);
|
console.log(' *** Invia Email a ' + to, 'template', template);
|
||||||
|
|
||||||
return email
|
return email.send({
|
||||||
.send({
|
template: template,
|
||||||
template: template,
|
message: {
|
||||||
message: {
|
to: to,
|
||||||
to: to,
|
},
|
||||||
},
|
locals: mylocalsconf,
|
||||||
locals: mylocalsconf,
|
}).then((ris) => {
|
||||||
})
|
// console.log('ris EMAIL', ris);
|
||||||
.then((ris) => {
|
return !!ris;
|
||||||
// console.log('ris EMAIL', ris);
|
}).catch((err) => {
|
||||||
return !!ris
|
console.error('sendEmail_base Error: ', err);
|
||||||
})
|
return false;
|
||||||
.catch((err) => {
|
});
|
||||||
console.error('sendEmail_base Error: ', err);
|
|
||||||
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
|
// setup e-mail data with unicode symbols
|
||||||
var mailOptions = {
|
var mailOptions = {
|
||||||
@@ -141,24 +137,23 @@ module.exports = {
|
|||||||
html: html,
|
html: html,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (replyTo)
|
if (replyTo)
|
||||||
mailOptions['reply-to'] = replyTo;
|
mailOptions['reply-to'] = replyTo;
|
||||||
|
|
||||||
const smtpTransport = this.getTransport(mylocalsconf);
|
const smtpTransport = this.getTransport(mylocalsconf);
|
||||||
|
|
||||||
if (process.env.SEND_EMAIL === "1") {
|
if (process.env.SEND_EMAIL === '1') {
|
||||||
// console.log("SEND EMAIL...");
|
// console.log("SEND EMAIL...");
|
||||||
// send mail with defined transport object
|
// send mail with defined transport object
|
||||||
smtpTransport.sendMail(mailOptions, function (error, response) {
|
smtpTransport.sendMail(mailOptions, function(error, response) {
|
||||||
if (error) {
|
if (error) {
|
||||||
console.log("Email Inviata ERRORE RISPOSTA: " + error);
|
console.log('Email Inviata ERRORE RISPOSTA: ' + error);
|
||||||
} else {
|
} else {
|
||||||
// console.log("Email Inviata RISPOSTA: " + response);
|
// console.log("Email Inviata RISPOSTA: " + response);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
if (process.env.PROVA_EMAIL_TEMPLATE !== "1")
|
if (process.env.PROVA_EMAIL_TEMPLATE !== '1')
|
||||||
previewEmail(mailOptions).then(console.log).catch(console.error);
|
previewEmail(mailOptions).then(console.log).catch(console.error);
|
||||||
else
|
else
|
||||||
transport_preview.sendMail(mailOptions).then(console.log).catch(console.error);
|
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}`;
|
const strlinkreg = tools.getHostByIdApp(idapp) + process.env.LINKVERIF_REG + `?idapp=${idapp}&idlink=${idreg}`;
|
||||||
return strlinkreg;
|
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));
|
// 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)) {
|
if (tools.getConfSiteOptionEnabledByIdApp(mylocalsconf.idapp, shared_consts.ConfSite.Notif_Reg_Push_Admin)) {
|
||||||
const nometot = tools.getNomeCognomeEUserNameByUser(mylocalsconf);
|
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);
|
const numutenti = await User.getNumUsers(mylocalsconf.idapp);
|
||||||
tools.sendNotifToAdmin('++ [' + numutenti + '] ' + nometot + aportador);
|
tools.sendNotifToAdmin('++ [' + numutenti + '] ' + nometot + aportador);
|
||||||
@@ -215,7 +210,7 @@ module.exports = {
|
|||||||
// this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
// 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));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
@@ -228,7 +223,7 @@ module.exports = {
|
|||||||
emailto: emailto,
|
emailto: emailto,
|
||||||
iscritto,
|
iscritto,
|
||||||
metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento),
|
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);
|
mylocalsconf = this.setParamsForTemplate(iscritto, mylocalsconf);
|
||||||
@@ -247,39 +242,43 @@ 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));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
try {
|
||||||
|
|
||||||
let mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
locale: lang,
|
locale: lang,
|
||||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||||
strlinksito: tools.getHostByIdApp(idapp),
|
strlinksito: tools.getHostByIdApp(idapp),
|
||||||
emailto: emailto,
|
emailto: emailto,
|
||||||
iscritto,
|
iscritto,
|
||||||
metodo_pagamento: tools.getPaymentTypesById(iscritto.metodo_pagamento),
|
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);
|
mylocalsconf = this.setParamsForTemplate(iscritto, mylocalsconf);
|
||||||
|
|
||||||
this.sendEmail_base('iscrizione_arcadei/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
this.sendEmail_base('iscrizione_arcadei/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send to the Admin an Email
|
// Send to the Admin an Email
|
||||||
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_ARCADEI, mylocalsconf, 'MSG_ISCRITTO_ARCADEI');
|
await telegrambot.notifyIscrizioneToTelegram(telegrambot.phase.ISCRIZIONE_ARCADEI, mylocalsconf, 'MSG_ISCRITTO_ARCADEI');
|
||||||
|
|
||||||
tools.sendNotifToAdmin('Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
tools.sendNotifToAdmin('Iscrizione Arcadei : ' + mylocalsconf.name + ' ' + mylocalsconf.surname + ' (' + mylocalsconf.username + ')');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/iscrizione_arcadei/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
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 = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
@@ -295,12 +294,11 @@ module.exports = {
|
|||||||
this.sendEmail_base('resetpwd/' + lang, emailto, mylocalsconf, '');
|
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('sendEmail_Booking');
|
||||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||||
|
|
||||||
|
|
||||||
let mylocalsconf = {
|
let mylocalsconf = {
|
||||||
idapp,
|
idapp,
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
@@ -318,61 +316,62 @@ module.exports = {
|
|||||||
|
|
||||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||||
|
|
||||||
return await Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING')
|
return await Settings.getValDbSettings(idapp, 'MSG_REPLY_AFTER_BOOKING').then(async (ris) => {
|
||||||
.then(async (ris) => {
|
mylocalsconf.msgreply_after_booking = ris;
|
||||||
mylocalsconf.msgreply_after_booking = ris;
|
|
||||||
|
|
||||||
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Prenotazione');
|
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Prenotazione');
|
||||||
|
|
||||||
if (recbooking.modified) {
|
if (recbooking.modified) {
|
||||||
texthtml = 'modifybooking';
|
texthtml = 'modifybooking';
|
||||||
} else {
|
} else {
|
||||||
texthtml = 'makebooking';
|
texthtml = 'makebooking';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendEmail_base('booking/' + texthtml + '/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
this.sendEmail_base('booking/' + texthtml + '/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||||
|
|
||||||
// Send Email also to the Admin
|
// Send Email also to the Admin
|
||||||
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
|
|
||||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||||
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
preparaConfPerBooking: async function (res, idapp, mylocalsconf, recbooking, title) {
|
preparaConfPerBooking: async function(res, idapp, mylocalsconf, recbooking, title) {
|
||||||
|
|
||||||
let texthtml = '';
|
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) {
|
if (recbooking.modified) {
|
||||||
msgtelegram += ' (modificato) '
|
msgtelegram += ' (modificato) ';
|
||||||
} else {
|
} else {
|
||||||
msgtelegram += ' (Nuovo)'
|
msgtelegram += ' (Nuovo)';
|
||||||
}
|
}
|
||||||
|
|
||||||
msgtelegram += '\n';
|
msgtelegram += '\n';
|
||||||
|
|
||||||
if (recbooking.numpeople > 0) {
|
if (recbooking.numpeople > 0) {
|
||||||
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
|
mylocalsconf.participants = recbooking.numpeople.toString() + ' ' + tools.getres__('partecipanti', res);
|
||||||
msgtelegram += mylocalsconf.participants + '\n'
|
msgtelegram += mylocalsconf.participants + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recbooking.numpeopleLunch > 0) {
|
if (recbooking.numpeopleLunch > 0) {
|
||||||
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
|
mylocalsconf.participantsLunch = recbooking.numpeopleLunch.toString() + ' ' + tools.getres__('partecipanti a Pranzo', res);
|
||||||
msgtelegram += mylocalsconf.participantsLunch + '\n'
|
msgtelegram += mylocalsconf.participantsLunch + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recbooking.numpeopleDinner > 0) {
|
if (recbooking.numpeopleDinner > 0) {
|
||||||
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
|
mylocalsconf.participantsDinner = recbooking.numpeopleDinner.toString() + ' ' + tools.getres__('partecipanti a Cena', res);
|
||||||
msgtelegram += mylocalsconf.participantsDinner + '\n'
|
msgtelegram += mylocalsconf.participantsDinner + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recbooking.numpeopleDinnerShared > 0) {
|
if (recbooking.numpeopleDinnerShared > 0) {
|
||||||
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' + tools.getres__('partecipanti a Cena Condivisa', res);
|
mylocalsconf.participantsDinnerShared = recbooking.numpeopleDinnerShared.toString() + ' ' +
|
||||||
msgtelegram += mylocalsconf.participantsDinnerShared + '\n'
|
tools.getres__('partecipanti a Cena Condivisa', res);
|
||||||
|
msgtelegram += mylocalsconf.participantsDinnerShared + '\n';
|
||||||
}
|
}
|
||||||
|
|
||||||
telegrambot.sendMsgTelegramToTheManagers(idapp, msgtelegram);
|
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');
|
tools.mylog('sendEmail_CancelBooking');
|
||||||
|
|
||||||
@@ -404,7 +403,8 @@ module.exports = {
|
|||||||
|
|
||||||
mylocalsconf = await this.preparaConfPerBooking(res, idapp, mylocalsconf, recbooking, 'Cancellazione');
|
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);
|
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('sendEmail_Msg');
|
||||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||||
@@ -431,7 +431,7 @@ module.exports = {
|
|||||||
usernameorig: user.name + ' ' + user.surname,
|
usernameorig: user.name + ' ' + user.surname,
|
||||||
message: tools.convertTexttoHtml(recmsg.message),
|
message: tools.convertTexttoHtml(recmsg.message),
|
||||||
infoevent: recmsg.source.infoevent,
|
infoevent: recmsg.source.infoevent,
|
||||||
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id
|
strlinkreply: tools.getHostByIdApp(idapp) + '/messages/' + recmsg._id,
|
||||||
};
|
};
|
||||||
|
|
||||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||||
@@ -449,7 +449,7 @@ module.exports = {
|
|||||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
// 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');
|
tools.mylog('sendEmail_ByText');
|
||||||
|
|
||||||
@@ -478,7 +478,7 @@ module.exports = {
|
|||||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
// 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');
|
tools.mylog('sendEmail_ByNotif');
|
||||||
|
|
||||||
@@ -507,7 +507,7 @@ module.exports = {
|
|||||||
// this.sendEmail_base('admin/sendmsg/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf);
|
// 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));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
@@ -530,7 +530,7 @@ module.exports = {
|
|||||||
name: mylocalsconf.name,
|
name: mylocalsconf.name,
|
||||||
surname: mylocalsconf.surname,
|
surname: mylocalsconf.surname,
|
||||||
email: mylocalsconf.emailto,
|
email: mylocalsconf.emailto,
|
||||||
hash
|
hash,
|
||||||
});
|
});
|
||||||
myperson._id = new ObjectID();
|
myperson._id = new ObjectID();
|
||||||
} else {
|
} 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 {
|
} else {
|
||||||
// Already Esist
|
// Already Esist
|
||||||
return {
|
return {
|
||||||
code: server_constants.RIS_SUBSCRIBED_ALREADYEXIST,
|
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));
|
// console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||||
|
|
||||||
@@ -576,34 +576,35 @@ module.exports = {
|
|||||||
return {
|
return {
|
||||||
myperson: null,
|
myperson: null,
|
||||||
code: server_constants.RIS_UNSUBSCRIBED_ALREADY_DONE,
|
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 = {
|
const fields_to_update = {
|
||||||
statesub: false
|
statesub: false,
|
||||||
};
|
};
|
||||||
let myperson = await MailingList.findOneAndUpdate({
|
let myperson = await MailingList.findOneAndUpdate({
|
||||||
idapp,
|
idapp,
|
||||||
hash: hashemail
|
hash: hashemail,
|
||||||
}, { $set: fields_to_update }, { new: false });
|
}, {$set: fields_to_update}, {new: false});
|
||||||
if (myperson) {
|
if (myperson) {
|
||||||
return { myperson, code: server_constants.RIS_UNSUBSCRIBED_OK, msg: '' }
|
return {myperson, code: server_constants.RIS_UNSUBSCRIBED_OK, msg: ''};
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// Not found !
|
// Not found !
|
||||||
return {
|
return {
|
||||||
myperson: null,
|
myperson: null,
|
||||||
code: server_constants.RIS_UNSUBSCRIBED_NOT_EXIST,
|
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 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);
|
let out = myvar.replace('{urlunsubscribe}', urlunsibscribe);
|
||||||
out = out.replace('{email}', mylocalsconf.emailto);
|
out = out.replace('{email}', mylocalsconf.emailto);
|
||||||
@@ -612,20 +613,23 @@ module.exports = {
|
|||||||
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
out = out.replace('{surname}', mylocalsconf.surname ? mylocalsconf.surname : '');
|
||||||
out = out.replace('{aportador_solidario}', mylocalsconf.aportador_solidario ? mylocalsconf.aportador_solidario : '');
|
out = out.replace('{aportador_solidario}', mylocalsconf.aportador_solidario ? mylocalsconf.aportador_solidario : '');
|
||||||
|
|
||||||
return out
|
return out;
|
||||||
},
|
},
|
||||||
|
|
||||||
replacefields: function (mylocalsconf) {
|
replacefields: function(mylocalsconf) {
|
||||||
try {
|
try {
|
||||||
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disclaimer) : '';
|
mylocalsconf.dataemail.disclaimer_out = !!mylocalsconf.dataemail.disclaimer ? this.fieldsloop(mylocalsconf,
|
||||||
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf, mylocalsconf.dataemail.disc_bottom) : '';
|
mylocalsconf.dataemail.disclaimer) : '';
|
||||||
|
mylocalsconf.dataemail.disc_bottom_out = !!mylocalsconf.dataemail.disc_bottom ? this.fieldsloop(mylocalsconf,
|
||||||
|
mylocalsconf.dataemail.disc_bottom) : '';
|
||||||
if (mylocalsconf.dataemail.templ)
|
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) {
|
} catch (e) {
|
||||||
console.error('Error replacefields: ' + e)
|
console.error('Error replacefields: ' + e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mylocalsconf
|
return mylocalsconf;
|
||||||
},
|
},
|
||||||
|
|
||||||
getdataemail: async (idapp) => {
|
getdataemail: async (idapp) => {
|
||||||
@@ -654,10 +658,10 @@ module.exports = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// console.log(mydata.templemail_id);
|
// 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);
|
// console.log(mydata.templ);
|
||||||
|
|
||||||
return mydata
|
return mydata;
|
||||||
},
|
},
|
||||||
|
|
||||||
getTransport: (mylocalsconf) => {
|
getTransport: (mylocalsconf) => {
|
||||||
@@ -666,16 +670,17 @@ module.exports = {
|
|||||||
|
|
||||||
// console.log('mylocalsconf.dataemail', mylocalsconf.dataemail);
|
// 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({
|
smtpTransport = nodemailer.createTransport({
|
||||||
host: mylocalsconf.dataemail.email_service,
|
host: mylocalsconf.dataemail.email_service,
|
||||||
port: mylocalsconf.dataemail.email_port,
|
port: mylocalsconf.dataemail.email_port,
|
||||||
secureConnection: true,
|
secureConnection: true,
|
||||||
tls: { cipher: 'SSLv3' },
|
tls: {cipher: 'SSLv3'},
|
||||||
auth: {
|
auth: {
|
||||||
user: mylocalsconf.dataemail.from,
|
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) {
|
} else if (mylocalsconf.dataemail.email_service === 'gmail' && !!mylocalsconf.dataemail.pwd_from) {
|
||||||
|
|
||||||
@@ -684,8 +689,8 @@ module.exports = {
|
|||||||
service: 'gmail', //'Gmail',
|
service: 'gmail', //'Gmail',
|
||||||
auth: {
|
auth: {
|
||||||
user: mylocalsconf.dataemail.from,
|
user: mylocalsconf.dataemail.from,
|
||||||
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from)
|
pass: tools.decryptdata(mylocalsconf.dataemail.pwd_from),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// smtpTransport = {
|
// smtpTransport = {
|
||||||
@@ -693,8 +698,8 @@ module.exports = {
|
|||||||
service: 'gmail',
|
service: 'gmail',
|
||||||
auth: {
|
auth: {
|
||||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
pass: tools.getPwdByIdApp(mylocalsconf.idapp),
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -703,7 +708,7 @@ module.exports = {
|
|||||||
return smtpTransport;
|
return smtpTransport;
|
||||||
},
|
},
|
||||||
|
|
||||||
setParamsForTemplate: function (user, mylocalsconf){
|
setParamsForTemplate: function(user, mylocalsconf) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mylocalsconf.username = user.username;
|
mylocalsconf.username = user.username;
|
||||||
@@ -715,14 +720,14 @@ module.exports = {
|
|||||||
mylocalsconf.user = user;
|
mylocalsconf.user = user;
|
||||||
|
|
||||||
mylocalsconf = this.replacefields(mylocalsconf);
|
mylocalsconf = this.replacefields(mylocalsconf);
|
||||||
}catch (e) {
|
} catch (e) {
|
||||||
console.error('setParamsForTemplate', e);
|
console.error('setParamsForTemplate', e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mylocalsconf;
|
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;
|
const msginizio = 'Ordine n: ' + orders.numorder + ' ' + user.name + ' ' + user.surname;
|
||||||
console.log(msginizio);
|
console.log(msginizio);
|
||||||
@@ -737,15 +742,16 @@ module.exports = {
|
|||||||
baseurl: tools.getHostByIdApp(idapp),
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
ordernumber: orders.numorder,
|
ordernumber: orders.numorder,
|
||||||
user
|
user,
|
||||||
};
|
};
|
||||||
|
|
||||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
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);
|
const msginizio = 'INIZIO - sendEmail_Order ' + ordertype + ': ' + tools.getNomeAppByIdApp(idapp);
|
||||||
console.log(msginizio);
|
console.log(msginizio);
|
||||||
@@ -760,13 +766,14 @@ module.exports = {
|
|||||||
baseurl: tools.getHostByIdApp(idapp),
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
dataemail: await this.getdataemail(idapp),
|
dataemail: await this.getdataemail(idapp),
|
||||||
ordernumber: orders.numorder,
|
ordernumber: orders.numorder,
|
||||||
user
|
user,
|
||||||
};
|
};
|
||||||
|
|
||||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||||
|
|
||||||
if ((status !== shared_consts.OrderStatus.CANCELED) && (status !== shared_consts.OrderStatus.RECEIVED)) {
|
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, '');
|
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);
|
const msginizio = 'INIZIO - sendEmail_Newsletter_Events: ' + tools.getNomeAppByIdApp(idapp);
|
||||||
console.log(msginizio);
|
console.log(msginizio);
|
||||||
@@ -795,12 +802,12 @@ module.exports = {
|
|||||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||||
arrevents: myarrevents,
|
arrevents: myarrevents,
|
||||||
baseurl: tools.getHostByIdApp(idapp),
|
baseurl: tools.getHostByIdApp(idapp),
|
||||||
dataemail: await this.getdataemail(idapp)
|
dataemail: await this.getdataemail(idapp),
|
||||||
};
|
};
|
||||||
|
|
||||||
await Newstosent.processingJob(id_newstosent, true);
|
await Newstosent.processingJob(id_newstosent, true);
|
||||||
|
|
||||||
const mynewsrec = await Newstosent.findOne({ _id: id_newstosent });
|
const mynewsrec = await Newstosent.findOne({_id: id_newstosent});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mynewsrec.numemail_tot = userstosend.length;
|
mynewsrec.numemail_tot = userstosend.length;
|
||||||
@@ -829,7 +836,7 @@ module.exports = {
|
|||||||
await mynewsrec.save();
|
await mynewsrec.save();
|
||||||
await Newstosent.processingJob(id_newstosent, false);
|
await Newstosent.processingJob(id_newstosent, false);
|
||||||
console.log('*** L\'Invio della Newsletter è stato fermato ! ');
|
console.log('*** L\'Invio della Newsletter è stato fermato ! ');
|
||||||
return false
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
mylocalsconf = this.setParamsForTemplate(user, mylocalsconf);
|
||||||
@@ -843,7 +850,8 @@ module.exports = {
|
|||||||
|
|
||||||
// Send Email to the User
|
// Send Email to the User
|
||||||
// console.log('-> Invio Email (', mynewsrec.numemail_sent, '/', mynewsrec.numemail_tot, ')');
|
// 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) {
|
if ((mynewsrec.numemail_sent % 100) === 0) {
|
||||||
const msgproc = 'In Corso ' + mynewsrec.numemail_sent + ' / ' + mynewsrec.numemail_tot + ' Email inviate...';
|
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.
|
//Put the result in the database, to check if is sent or not.
|
||||||
const updateml = await MailingList.findOneAndUpdate({
|
const updateml = await MailingList.findOneAndUpdate({
|
||||||
idapp,
|
idapp,
|
||||||
email: user.email
|
email: user.email,
|
||||||
}, { $set: { lastid_newstosent: ObjectID(id_newstosent) } }, { new: false });
|
}, {$set: {lastid_newstosent: ObjectID(id_newstosent)}}, {new: false});
|
||||||
|
|
||||||
|
|
||||||
//Delay for send email...
|
//Delay for send email...
|
||||||
await tools.snooze(secpause);
|
await tools.snooze(secpause);
|
||||||
@@ -894,55 +901,50 @@ module.exports = {
|
|||||||
await mynewsrec.save();
|
await mynewsrec.save();
|
||||||
await Newstosent.processingJob(id_newstosent, false);
|
await Newstosent.processingJob(id_newstosent, false);
|
||||||
console.log('*** L\'Invio della Newsletter è stato fermato ! ');
|
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
|
// Check if is the time to send the Newsletter
|
||||||
|
|
||||||
return await Newstosent.findNewsletter_To_Send(idapp)
|
return await Newstosent.findNewsletter_To_Send(idapp).then((rec) => {
|
||||||
.then((rec) => {
|
if (rec)
|
||||||
if (rec)
|
this.sendNewsletter(rec);
|
||||||
this.sendNewsletter(rec);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
,
|
,
|
||||||
|
|
||||||
checkifPendingNewsletter: async function (idapp) {
|
checkifPendingNewsletter: async function(idapp) {
|
||||||
// Check if is the time to send the Newsletter
|
// Check if is the time to send the Newsletter
|
||||||
// Only newsletter pending en 8 hour last email sent.
|
// Only newsletter pending en 8 hour last email sent.
|
||||||
|
|
||||||
return await Newstosent.findNewsletterPending_To_Send(idapp)
|
return await Newstosent.findNewsletterPending_To_Send(idapp).then((rec) => { //
|
||||||
.then((rec) => { //
|
this.sendNewsletter(rec, idapp);
|
||||||
this.sendNewsletter(rec, idapp)
|
});
|
||||||
});
|
|
||||||
},
|
},
|
||||||
|
|
||||||
sendNewsletter: async function (rec, idapp) {
|
sendNewsletter: async function(rec, idapp) {
|
||||||
if (rec) {
|
if (rec) {
|
||||||
// Start the job
|
// Start the job
|
||||||
let myjobnews = await Newstosent.findOne({ _id: rec._id });
|
let myjobnews = await Newstosent.findOne({_id: rec._id});
|
||||||
if (!!myjobnews) {
|
if (!!myjobnews) {
|
||||||
myjobnews.starting_job = true;
|
myjobnews.starting_job = true;
|
||||||
myjobnews.datestartJob = new Date();
|
myjobnews.datestartJob = new Date();
|
||||||
|
|
||||||
myjobnews.save()
|
myjobnews.save().then((ris) => {
|
||||||
.then((ris) => {
|
|
||||||
|
|
||||||
this.sendEmail_Newsletter_Events("it", idapp, rec._id);
|
this.sendEmail_Newsletter_Events('it', idapp, rec._id);
|
||||||
})
|
}).catch((e) => {
|
||||||
.catch((e) => {
|
console.error(e.message);
|
||||||
console.error(e.message);
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
testemail: async function (idapp, lang, previewonly) {
|
testemail: async function(idapp, lang, previewonly) {
|
||||||
|
|
||||||
const myarrevents = await MyEvent.getLastEvents(idapp);
|
const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||||
const myemail = await Settings.getValDbSettings(idapp, 'EMAIL_TEST');
|
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> ';
|
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');
|
/*const htmlToText = require('html-to-text');
|
||||||
@@ -994,11 +995,10 @@ module.exports = {
|
|||||||
|
|
||||||
return await this.sendEmail_ByText(lang, email, myuser, idapp, {
|
return await this.sendEmail_ByText(lang, email, myuser, idapp, {
|
||||||
emailbody: messaggio,
|
emailbody: messaggio,
|
||||||
emailtitle: mytitle
|
emailtitle: mytitle,
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
},
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ const tools = require('../tools/general');
|
|||||||
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
const appTelegram = [tools.FREEPLANET, tools.RISO];
|
||||||
|
|
||||||
const appTelegram_TEST = [tools.FREEPLANET, tools.ARCADEI, 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 appTelegramFinti = ['2', tools.CNM, tools.ARCADEI];
|
||||||
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET];
|
const appTelegramDest = [tools.FREEPLANET, tools.FREEPLANET, tools.FREEPLANET];
|
||||||
|
|
||||||
const printf = require('util').format;
|
const printf = require('util').format;
|
||||||
|
|
||||||
@@ -269,8 +269,8 @@ const Menu = {
|
|||||||
'Inv e NO 7 Req',
|
'Inv e NO 7 Req',
|
||||||
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
MSGSTAFF: emoji.get('incoming_envelope') + ' Invia a STAFF',
|
||||||
MSGPAOLO: emoji.get('incoming_envelope') + ' Invia a PAOLO',
|
MSGPAOLO: emoji.get('incoming_envelope') + ' Invia a PAOLO',
|
||||||
RESTART_SRV: emoji.get('incoming_envelope') + 'RestartServer',
|
RESTART_SRV: emoji.get('incoming_envelope') + 'Restart-NodeJs',
|
||||||
REBOOT_SRV: emoji.get('incoming_envelope') + 'RebootServer',
|
REBOOT_SRV: emoji.get('incoming_envelope') + 'Reboot-VPS!',
|
||||||
EXECSH: emoji.get('incoming_envelope') + 'ExecSH',
|
EXECSH: emoji.get('incoming_envelope') + 'ExecSH',
|
||||||
LOG_SRV: '🖥Logserver.sh',
|
LOG_SRV: '🖥Logserver.sh',
|
||||||
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
|
MSGATUTTI: emoji.get('incoming_envelope') + ' Invia a TUTTI',
|
||||||
@@ -504,8 +504,8 @@ const txt = {
|
|||||||
MSG_APORTADOR_DEST_NOT_CONFIRMED: emo.EXCLAMATION_MARK +
|
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 !',
|
'🚫 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_APORTADOR_NOT_CONFIRMED: emo.EXCLAMATION_MARK + '🚫 %s Non è stato Abilitato !',
|
||||||
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%] Si è appena Iscritto al Conacreis "%s"',
|
MSG_ISCRITTO_CONACREIS: emo.FIRE + '[%s] Si è appena Iscritto al Conacreis "%s"',
|
||||||
MSG_ISCRITTO_ARCADEI: emo.FIRE + '[%] Si è appena Iscritto ad Arcadei "%s"',
|
MSG_ISCRITTO_ARCADEI: emo.FIRE + '[%s] Si è appena Iscritto ad Arcadei "%s"',
|
||||||
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
MSG_MSG_SENT: emoji.get('envelope') + ' Messaggi Inviati !',
|
||||||
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
MSG_MSG_TOSENT: emoji.get('envelope') + ' Messaggi da Inviare',
|
||||||
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
MSG_MSG_INCORSO: emoji.get('envelope') + ' messaggi in corso... Inviati attualmente',
|
||||||
@@ -813,7 +813,7 @@ const MyTelegramBot = {
|
|||||||
|
|
||||||
let nomeapp = tools.getHostByIdApp(mylocalsconf.idapp);
|
let nomeapp = tools.getHostByIdApp(mylocalsconf.idapp);
|
||||||
|
|
||||||
let text = printf(getstr(langdest, msg), nomeapp, NameFrom);
|
let text = printf(getstr(langdest, msg), NameFrom, nomeapp);
|
||||||
|
|
||||||
let addtext = '';
|
let addtext = '';
|
||||||
|
|
||||||
|
|||||||
@@ -412,8 +412,8 @@ module.exports = {
|
|||||||
FREEPLANET: '1',
|
FREEPLANET: '1',
|
||||||
AYNI: '7',
|
AYNI: '7',
|
||||||
CNM: '10',
|
CNM: '10',
|
||||||
ARCADEI: '14',
|
|
||||||
RISO: '13',
|
RISO: '13',
|
||||||
|
ARCADEI: '15',
|
||||||
|
|
||||||
HELP_CHAT: '',
|
HELP_CHAT: '',
|
||||||
TYPECONF_ZOOM: 'zoom',
|
TYPECONF_ZOOM: 'zoom',
|
||||||
|
|||||||
Reference in New Issue
Block a user