Skip to content
Snippets Groups Projects
Commit ddff84fb authored by kuzdogan's avatar kuzdogan
Browse files

Skip error emails if all contacts are found

parent d6f2af9c
Branches
No related tags found
No related merge requests found
......@@ -29,7 +29,7 @@ const transport = nodemailer.createTransport({
exports.sendNoticeMails = (contactsArray) => {
let promises = [];
for (let i = 0; i < contactsArray.length; i++) {
promises.push(setTimeout(() => sendNoticeMail(contactsArray[i]), 2500 * i)) // Avoid sending too much at once
promises.push(setTimeout(() => sendNoticeMail(contactsArray[i]), 3000 * i)) // Avoid sending too much at once
}
return Promise.all(promises);
}
......@@ -62,6 +62,8 @@ exports.sendErrorEmails = (emails, error) => {
* @param {Error} error - the thrown Error object
*/
exports.sendNotFoundEmails = (emails, notFoundContacts) => {
if (notFoundContacts.length < 1)
return Promise.resolve();
logger.log('Sending not found emails to ' + emails.join() + ' for the addresses: ' + notFoundContacts.map(contact => contact.address).join())
const message = {
from: `bloxberg Validator Monitoring <monitoring@bloxberg.org>`,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment