Merge branch 'feature/log_mails'
This commit is contained in:
+14
-18
@@ -181,10 +181,7 @@ class MailReader():
|
||||
return mail_messages
|
||||
|
||||
|
||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
# return True
|
||||
# if len(successful_items) == 0:
|
||||
# return False
|
||||
def need_to_valid_url(url: str, email, successful_items):
|
||||
print("url is :" + url)
|
||||
parts = url.split('/')
|
||||
id = parts[5]
|
||||
@@ -192,16 +189,19 @@ def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
for item in successful_items:
|
||||
if item.id == id:
|
||||
if item.url_validated is not None:
|
||||
return not item.url_validated
|
||||
return item, not item.url_validated
|
||||
else:
|
||||
# if url_validated is None
|
||||
if item.url_validated is not None:
|
||||
return not item.url_validated
|
||||
return True
|
||||
return True
|
||||
return item, not item.url_validated
|
||||
return item, True
|
||||
for item in successful_items:
|
||||
if item.mail == email:
|
||||
return item, True
|
||||
return None, True
|
||||
else:
|
||||
print("id not valid:{}".format(id))
|
||||
return False
|
||||
return None, False
|
||||
|
||||
|
||||
def need_to_check_email(mail: str, successful_items) -> bool:
|
||||
@@ -256,20 +256,16 @@ 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:
|
||||
# if mail.isImapClient:
|
||||
# match = re.search(PART_VALIDATION_URL_REGEX, mail.body.replace("\n", ""))
|
||||
# else:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
# url_to_validate = match.group(0)
|
||||
# if mail.isImapClient:
|
||||
# url = "https://rendezvousparis.hermes.com/" + url_to_validate.replace("3D", "")
|
||||
# else:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, _all_contact_list)
|
||||
_item, is_need_to = need_to_valid_url(url, mail.to_address, _refreshed_successful_items)
|
||||
if is_need_to:
|
||||
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