diff --git a/Assistant.js b/Assistant.js index 5681e0447..8ceffa1ce 100644 --- a/Assistant.js +++ b/Assistant.js @@ -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); } } + }; \ No newline at end of file