filter blacklisted items before booking
This commit is contained in:
+12
-1
@@ -25,8 +25,19 @@ async function filterBlacklistedContacts(contactList) {
|
||||
let blackListedContacts = await mongoManager.getAllBlackedListItems(collectionName);
|
||||
let contactsToBook = [];
|
||||
contactList.forEach((contact) => {
|
||||
if (blackListedContacts.find((bookedContact) => bookedContact.email === contact.mail) === undefined) {
|
||||
let blackListedItem = blackListedContacts.find((bookedContact) => bookedContact.email === contact.mail)
|
||||
if (blackListedItem === undefined) {
|
||||
contactsToBook.push(contact)
|
||||
} else {
|
||||
console.log("=====handle blacklist item before booking====");
|
||||
console.log("update_at_s is " + blackListedItem.update_at_in_s)
|
||||
console.log("black list email is " + blackListedItem.mail)
|
||||
let needToBook = blackListedItem.update_at_in_s + SEVEN_DAYS_IN_S <= (new Date()) / 1000;
|
||||
if (!needToBook) {
|
||||
console.log("contact in blacklist -->skip");
|
||||
} else {
|
||||
contactsToBook.push(contact)
|
||||
}
|
||||
}
|
||||
})
|
||||
return contactsToBook;
|
||||
|
||||
Reference in New Issue
Block a user