check if contact already requested or not
This commit is contained in:
@@ -1,13 +1,20 @@
|
||||
import time
|
||||
|
||||
from src import params, definitions
|
||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.pojo.contact_pojo import ContactPojo
|
||||
|
||||
SEVEN_DAYS_IN_S = 7 * 24 * 3600
|
||||
|
||||
|
||||
def can_send_request(contact: ContactPojo) -> bool:
|
||||
def is_already_sent(contact: ContactPojo) -> bool:
|
||||
already_sent_contacts = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
for required_contact in already_sent_contacts:
|
||||
if contact.mail == required_contact.email:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_in_white_list(contact: ContactPojo) -> bool:
|
||||
black_list = MONGO_STORE_MANAGER.get_blacklist_contacts()
|
||||
for black_contact in black_list:
|
||||
if contact.mail == black_contact.mail:
|
||||
@@ -15,3 +22,7 @@ def can_send_request(contact: ContactPojo) -> bool:
|
||||
return black_contact.update_at_in_s + SEVEN_DAYS_IN_S < time.time()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def can_send_request(contact: ContactPojo) -> bool:
|
||||
return is_in_white_list(contact) and (not is_already_sent(contact=contact))
|
||||
|
||||
Reference in New Issue
Block a user