diff --git a/mail/mail_reader_all_contacts.py b/mail/mail_reader_all_contacts.py index 3e2232f..8a747e8 100755 --- a/mail/mail_reader_all_contacts.py +++ b/mail/mail_reader_all_contacts.py @@ -30,7 +30,7 @@ def check_email_address(email): print("Valid Email") return True else: - print("Invalid Email") + print("Invalid Email:" + email) return False @@ -203,16 +203,12 @@ def need_to_valid_url(url: str, successful_items) -> bool: parts = url.split('/') id = parts[5] if len(id) == 6: - if id == "CS93VB": - print("found") for item in successful_items: if item.id == id: if item.url_validated is not None: return 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 else: @@ -236,7 +232,7 @@ def need_to_check_email(mail: str, successful_items) -> bool: return True -def find_links_to_validate_from_mail_list(mail_list: list): +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() @@ -252,14 +248,14 @@ def find_links_to_validate_from_mail_list(mail_list: list): # 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, successful_items): - print("need to validate url: " + url) + 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: - print("do not need to click url --> {}".format(mail.mail_address)) + logger.info("do not need to click url --> {}".format(mail.mail_address))