Merge branch 'feature/save_ip'
This commit is contained in:
@@ -231,31 +231,32 @@ def need_to_check_email(mail: str, successful_items) -> bool:
|
||||
|
||||
def find_links_to_validate_from_mail_list(mail_list: list, logger):
|
||||
# check time before start checking emails
|
||||
contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list()
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
mails_messages = []
|
||||
with ThreadPoolExecutor(max_workers=len(mail_list)) as executor:
|
||||
for mail in mail_list:
|
||||
# check whether we need to read mail
|
||||
if need_to_check_email(mail.mail, successful_items):
|
||||
mail_reader = MailReader(mail.mail, mail.password)
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
# for mail in mail_list:
|
||||
# # check whether we need to read mail
|
||||
# if need_to_check_email(mail.mail, successful_items):
|
||||
# mail_reader = MailReader(mail.mail, mail.password)
|
||||
# mail_reader.read_emails(mails_messages)
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
for mail in mails_messages:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
logger.info("need to validate url: " + url)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,
|
||||
_all_contact_list=contact_to_book_list)
|
||||
else:
|
||||
logger.info("do not need to click url --> {}".format(mail.mail_address))
|
||||
if len(mail_list) > 0:
|
||||
contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list()
|
||||
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
mails_messages = []
|
||||
with ThreadPoolExecutor(max_workers=len(mail_list)) as executor:
|
||||
for mail in mail_list:
|
||||
# check whether we need to read mail
|
||||
if need_to_check_email(mail.mail, successful_items):
|
||||
mail_reader = MailReader(mail.mail, mail.password)
|
||||
executor.submit(mail_reader.read_emails, mails_messages)
|
||||
# for mail in mail_list:
|
||||
# # check whether we need to read mail
|
||||
# if need_to_check_email(mail.mail, successful_items):
|
||||
# mail_reader = MailReader(mail.mail, mail.password)
|
||||
# mail_reader.read_emails(mails_messages)
|
||||
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
|
||||
for mail in mails_messages:
|
||||
match = re.search(VALIDATION_URL_REGEX, mail.body)
|
||||
if match:
|
||||
url = match.group(0)
|
||||
if need_to_valid_url(url, _refreshed_successful_items):
|
||||
logger.info("need to validate url: " + url)
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,
|
||||
_all_contact_list=contact_to_book_list)
|
||||
else:
|
||||
logger.info("do not need to click url --> {}".format(mail.mail_address))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
Reference in New Issue
Block a user