Improving email function
This commit is contained in:
1 parent
20df7ba890
commit
919f8946ae
1 file changed
+7
-11
+7
-11
@@ -1312,14 +1312,11 @@
|
||||
}
|
||||
|
||||
function sendMessage(pRelevance, pTitle, pBody) {
|
||||
let runIndex = context.statusReport.runs.length - 1;
|
||||
|
||||
context.newHistoryRecord.messageRelevance = pRelevance;
|
||||
context.newHistoryRecord.messageTitle = pTitle;
|
||||
context.newHistoryRecord.messageTitle = bot.startMode + "." + runIndex +": "+ pTitle;
|
||||
context.newHistoryRecord.messageBody = pBody;
|
||||
|
||||
if(pRelevance > 6){
|
||||
sendEmail(pTitle, pBody, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1347,12 +1344,10 @@
|
||||
|
||||
}
|
||||
|
||||
function sendEmail(pTitle, pBody, pSendToAdmins) {
|
||||
function sendEmail(pTitle, pBody, pTo) {
|
||||
try {
|
||||
let emailList = global.EMAIL_CONFIG.distributionList;
|
||||
if (pSendToAdmins) {
|
||||
emailList = global.EMAIL_CONFIG.adminList;
|
||||
}
|
||||
let emailList = pTo; //TODO Pending to add spam controller
|
||||
let runIndex = context.statusReport.runs.length - 1;
|
||||
|
||||
let transporter = nodemailer.createTransport({
|
||||
service: global.EMAIL_CONFIG.service,
|
||||
@@ -1365,7 +1360,7 @@
|
||||
let mailOptions = {
|
||||
from: global.EMAIL_CONFIG.from,
|
||||
bcc: emailList,
|
||||
subject: bot.startMode + ' - ' + pTitle,
|
||||
subject: bot.startMode + "." + runIndex + ' - ' + pTitle,
|
||||
text: pBody
|
||||
};
|
||||
|
||||
@@ -1381,4 +1376,5 @@
|
||||
logger.write(MODULE_NAME, "[ERROR] sendEmail -> err = " + err.message);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
Reference in new issue
Block a user