- Profile
- Bot Telegram - fixed Chip multiselect
This commit is contained in:
@@ -58,21 +58,26 @@ module.exports = {
|
||||
}
|
||||
|
||||
// if (!transport) {
|
||||
// transport = this.getTransport();
|
||||
// transport = this.getTransport(mylocalsconf);
|
||||
// }
|
||||
|
||||
// console.log('1 . transport', transport);
|
||||
|
||||
if (transport) {
|
||||
paramemail.transport = transport;
|
||||
} else {
|
||||
// console.log('1b . transport gmail');
|
||||
paramemail.transport = {
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: process.env.EMAIL_FROM,
|
||||
pass: process.env.EMAIL_PW
|
||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// console.log('2 . paramemail.transport', paramemail.transport);
|
||||
|
||||
// console.log('paramemail', paramemail);
|
||||
|
||||
const email = new Email(paramemail);
|
||||
@@ -86,11 +91,11 @@ module.exports = {
|
||||
locals: mylocalsconf,
|
||||
})
|
||||
.then((ris) => {
|
||||
console.log('ris EMAIL', ris);
|
||||
// console.log('ris EMAIL', ris);
|
||||
return !!ris
|
||||
})
|
||||
.catch((err) => {
|
||||
console.error('Error: ', err);
|
||||
console.error('sendEmail_base Error: ', err);
|
||||
return false
|
||||
});
|
||||
},
|
||||
@@ -99,7 +104,7 @@ module.exports = {
|
||||
|
||||
// setup e-mail data with unicode symbols
|
||||
var mailOptions = {
|
||||
from: process.env.EMAIL_FROM, // sender address
|
||||
from: tools.getEmailByIdApp(mylocalsconf.idapp), // sender address
|
||||
to: to,
|
||||
generateTextFromHTML: true,
|
||||
subject: subject,
|
||||
@@ -110,13 +115,13 @@ module.exports = {
|
||||
mailOptions['reply-to'] = replyTo;
|
||||
|
||||
if (process.env.SEND_EMAIL === 1) {
|
||||
console.log("SEND EMAIL smtpTransport");
|
||||
console.log("SEND EMAIL...");
|
||||
// send mail with defined transport object
|
||||
smtpTransport.sendMail(mailOptions, function (error, response) {
|
||||
if (error) {
|
||||
console.log(error);
|
||||
} else {
|
||||
console.log("Message sent: " + response);
|
||||
console.log("Email Inviata RISPOSTA: " + response);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
@@ -148,6 +153,7 @@ module.exports = {
|
||||
console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
@@ -157,20 +163,22 @@ module.exports = {
|
||||
surname: user.surname,
|
||||
forgetpwd: "",
|
||||
emailto: emailto,
|
||||
user,
|
||||
};
|
||||
|
||||
this.sendEmail_base('registration/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||
|
||||
// Send to the Admin an Email
|
||||
this.sendEmail_base('admin/registration/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/registration/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/registration/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
},
|
||||
sendEmail_RequestNewPassword: async function (lang, emailto, idapp, tokenforgot) {
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
@@ -188,6 +196,7 @@ module.exports = {
|
||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
@@ -216,10 +225,10 @@ module.exports = {
|
||||
this.sendEmail_base('booking/' + texthtml + '/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||
|
||||
// Send Email also to the Admin
|
||||
this.sendEmail_base('admin/' + texthtml + '/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/' + texthtml + '/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/' + texthtml + '/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
|
||||
}));
|
||||
@@ -231,6 +240,7 @@ module.exports = {
|
||||
tools.mylog('sendEmail_CancelBooking');
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
@@ -248,10 +258,10 @@ module.exports = {
|
||||
this.sendEmail_base('booking/cancelbooking/' + lang, emailto, mylocalsconf, tools.getreplyToEmailByIdApp(idapp));
|
||||
|
||||
// Send Email also to the Admin
|
||||
this.sendEmail_base('admin/cancelbooking/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/cancelbooking/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/cancelbooking/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/cancelbooking/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
},
|
||||
|
||||
@@ -261,6 +271,7 @@ module.exports = {
|
||||
tools.mylog('tools.getNomeAppByIdApp(idapp)', tools.getNomeAppByIdApp(idapp), idapp);
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
@@ -289,13 +300,13 @@ module.exports = {
|
||||
console.log('idapp', idapp, tools.getNomeAppByIdApp(idapp));
|
||||
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
dataemail: await this.getdataemail(idapp),
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
name: user.name,
|
||||
surname: user.surname,
|
||||
emailto: user.email,
|
||||
idapp
|
||||
};
|
||||
|
||||
const hash = tools.getHash(mylocalsconf.emailto);
|
||||
@@ -327,10 +338,10 @@ module.exports = {
|
||||
|
||||
if (sendnews) {
|
||||
// Send to the Admin an Email
|
||||
this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/added_to_newsletter/' + tools.LANGADMIN, tools.getAdminEmailByIdApp(idapp), mylocalsconf, '');
|
||||
|
||||
if (tools.isManagAndAdminDifferent(idapp)) {
|
||||
this.sendEmail_base('admin/added_to_newsletter/' + lang, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
this.sendEmail_base('admin/added_to_newsletter/' + tools.LANGADMIN, tools.getManagerEmailByIdApp(idapp), mylocalsconf, '');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -432,7 +443,7 @@ module.exports = {
|
||||
return mydata
|
||||
},
|
||||
|
||||
getTransport: () => {
|
||||
getTransport: (mylocalsconf) => {
|
||||
// Create Transport
|
||||
let smtpTransport = null;
|
||||
|
||||
@@ -445,7 +456,7 @@ module.exports = {
|
||||
pass: mylocalsconf.dataemail.pwd_from
|
||||
}
|
||||
});
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail') {
|
||||
} else if (mylocalsconf.dataemail.email_service === 'gmail' && mylocalsconf.dataemail.email_service !== undefined) {
|
||||
smtpTransport = {
|
||||
service: 'gmail', //'Gmail',
|
||||
auth: {
|
||||
@@ -457,8 +468,8 @@ module.exports = {
|
||||
smtpTransport = {
|
||||
service: 'gmail',
|
||||
auth: {
|
||||
user: process.env.EMAIL_FROM,
|
||||
pass: process.env.EMAIL_PW
|
||||
user: tools.getEmailByIdApp(mylocalsconf.idapp),
|
||||
pass: tools.getPwdByIdApp(mylocalsconf.idapp)
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -476,8 +487,8 @@ module.exports = {
|
||||
const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||
|
||||
mylocalsconf = {
|
||||
locale: lang,
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
arrevents: myarrevents,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
@@ -492,7 +503,7 @@ module.exports = {
|
||||
mynewsrec.templemail_str = mylocalsconf.dataemail.templ.subject;
|
||||
mynewsrec.numemail_sent = await MailingList.getnumSent(idapp, id_newstosent);
|
||||
|
||||
const smtpTransport = this.getTransport();
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
// LOOP USERS EMAIL
|
||||
for (const user of userstosend) {
|
||||
@@ -500,7 +511,7 @@ module.exports = {
|
||||
const isok = await MailingList.isOk(idapp, user._id, id_newstosent);
|
||||
if (isok) {
|
||||
let secpause = await Settings.getValDbSettings(idapp, 'MSEC_PAUSE_SEND', process.env.DELAY_SENDEMAIL);
|
||||
if (secpause > process.env.DELAY_SENDEMAIL)
|
||||
if (secpause < process.env.DELAY_SENDEMAIL)
|
||||
secpause = process.env.DELAY_SENDEMAIL;
|
||||
|
||||
activate = await Newstosent.isActivated(id_newstosent);
|
||||
@@ -607,13 +618,13 @@ module.exports = {
|
||||
const myarrevents = await MyEvent.getLastEvents(idapp);
|
||||
const myemail = await Settings.getValDbSettings(idapp, 'EMAIL_TEST');
|
||||
mylocalsconf = {
|
||||
idapp,
|
||||
locale: lang,
|
||||
nomeapp: tools.getNomeAppByIdApp(idapp),
|
||||
arrevents: myarrevents,
|
||||
name: 'TestNome',
|
||||
surname: 'TestCognome',
|
||||
emailto: myemail,
|
||||
idapp,
|
||||
baseurl: tools.getHostByIdApp(idapp),
|
||||
hashemail: tools.getHash(myemail),
|
||||
};
|
||||
@@ -625,7 +636,7 @@ module.exports = {
|
||||
|
||||
this.replacefields(mylocalsconf);
|
||||
|
||||
const smtpTransport = this.getTransport();
|
||||
const smtpTransport = this.getTransport(mylocalsconf);
|
||||
|
||||
console.log('-> Invio Email TEST a', mylocalsconf.emailto, 'previewonly', previewonly);
|
||||
return this.sendEmail_base('newsletter/' + lang, mylocalsconf.emailto, mylocalsconf, '', smtpTransport, previewonly);
|
||||
|
||||
Reference in New Issue
Block a user