update mails configurations

This commit is contained in:
2024-05-10 14:33:05 +02:00
parent 0e94e754b2
commit 42ff1426d6
+6 -10
View File
@@ -30,7 +30,7 @@ def check_email_address(email):
print("Valid Email") print("Valid Email")
return True return True
else: else:
print("Invalid Email") print("Invalid Email:" + email)
return False return False
@@ -203,16 +203,12 @@ def need_to_valid_url(url: str, successful_items) -> bool:
parts = url.split('/') parts = url.split('/')
id = parts[5] id = parts[5]
if len(id) == 6: if len(id) == 6:
if id == "CS93VB":
print("found")
for item in successful_items: for item in successful_items:
if item.id == id: if item.id == id:
if item.url_validated is not None: if item.url_validated is not None:
return not item.url_validated return not item.url_validated
else: else:
# if url_validated is None # if url_validated is None
if item.url_validated is not None:
return not item.url_validated
return True return True
return True return True
else: else:
@@ -236,7 +232,7 @@ def need_to_check_email(mail: str, successful_items) -> bool:
return True 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 # check time before start checking emails
contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list() contact_to_book_list = MONGO_STORE_MANAGER.get_all_contact_to_book_list()
successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day() 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): # if need_to_check_email(mail.mail, successful_items):
# mail_reader = MailReader(mail.mail, mail.password) # mail_reader = MailReader(mail.mail, mail.password)
# mail_reader.read_emails(mails_messages) # mail_reader.read_emails(mails_messages)
_refreshed_successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
for mail in mails_messages: for mail in mails_messages:
match = re.search(VALIDATION_URL_REGEX, mail.body) match = re.search(VALIDATION_URL_REGEX, mail.body)
if match: if match:
url = match.group(0) url = match.group(0)
if need_to_valid_url(url, successful_items): if need_to_valid_url(url, _refreshed_successful_items):
print("need to validate url: " + url) logger.info("need to validate url: " + url)
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address,
_all_contact_list=contact_to_book_list) _all_contact_list=contact_to_book_list)
else: else:
print("do not need to click url --> {}".format(mail.mail_address)) logger.info("do not need to click url --> {}".format(mail.mail_address))