add method to extract contact list with serial
This commit is contained in:
+15
-1
@@ -25,6 +25,7 @@ DESTINATION_EMAIL_LIST = "DESTINATION_EMAIL_LIST"
|
||||
LINKS_TO_VALIDATE = "LINKS_TO_VALIDATE"
|
||||
INVALID_EMAIL_LIST = "INVALID_EMAIL_LIST"
|
||||
ADRESSE_LIST = "address"
|
||||
CONTACT_LIST_SERIAL_MAP = "CONTACT_LIST_SERIAL_MAP"
|
||||
|
||||
|
||||
class MongoDbManager:
|
||||
@@ -318,8 +319,15 @@ class MongoDbManager:
|
||||
_all_contact_list.append(ContactPojo.from_firestore_dict(document))
|
||||
return _all_contact_list
|
||||
|
||||
def get_all_contact_serial_list(self) -> list:
|
||||
result_list = []
|
||||
cursor = self.db[CONTACT_LIST_SERIAL_MAP]
|
||||
for document in cursor.find():
|
||||
result_list.append(ContactPojo.from_firestore_dict(document))
|
||||
return result_list
|
||||
|
||||
def save_links_to_validate(self, link: str, mail_address: str, _all_contact_list: list,
|
||||
_item: Union[ReserveResultPojo, None]):
|
||||
_item: Union[ReserveResultPojo, None], contact_serial_map_list):
|
||||
collection_to_use = self.db[LINKS_TO_VALIDATE]
|
||||
updated_at = time.strftime("%H:%M:%S", time.localtime())
|
||||
_ip_country = "FR"
|
||||
@@ -328,6 +336,12 @@ class MongoDbManager:
|
||||
if _item:
|
||||
_model = _item.source_from
|
||||
serial = _item.serial
|
||||
if len(serial) == 0:
|
||||
for contact in contact_serial_map_list:
|
||||
if contact.mail == mail_address:
|
||||
serial = contact.serial
|
||||
_model = contact.model
|
||||
break
|
||||
|
||||
# find ip_country info
|
||||
for _contact in _all_contact_list:
|
||||
|
||||
@@ -256,6 +256,7 @@ def read_mails():
|
||||
# get ip_country info
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
_all_contact_list = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||
contact_serial_map_list = MONGO_STORE_MANAGER.get_all_contact_serial_list()
|
||||
with ThreadPoolExecutor(max_workers=10) as executor:
|
||||
for mail in mails_messages:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
@@ -263,7 +264,8 @@ def read_mails():
|
||||
url = match.group(0)
|
||||
_item, is_need_to = need_to_valid_url(url, _refreshed_successful_items)
|
||||
if is_need_to:
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, _all_contact_list, _item)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, _all_contact_list, _item,
|
||||
contact_serial_map_list)
|
||||
# url_validator = LinkValidator(url)
|
||||
print("need to validate url: " + url)
|
||||
# executor.submit(url_validator.start_page, params.get_proxy(ProxyType.OXYLABS), False)
|
||||
|
||||
Reference in New Issue
Block a user