add model and serial to LinkToValid table
This commit is contained in:
+11
-18
@@ -11,9 +11,8 @@ from imapclient import IMAPClient
|
||||
|
||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||
from src.logs.AppLogging import init_logger
|
||||
from src.mail.mail_constants import DOMAIN_HOTMAIL, create_imap, show_folders
|
||||
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
|
||||
from src.utils.excel_reader import ExcelHelper
|
||||
from src.mail.mail_constants import create_imap, show_folders
|
||||
from src.pojo.mail.mail_pojo import MailPojo
|
||||
from src.utils.timeutiles import is_time_between
|
||||
|
||||
VALIDATION_URL_SUBJECT_fr = 'Votre demande de rendez-vous'
|
||||
@@ -182,7 +181,7 @@ class MailReader():
|
||||
return mail_messages
|
||||
|
||||
|
||||
def need_to_valid_url(url: str, successful_items) -> bool:
|
||||
def need_to_valid_url(url: str, successful_items):
|
||||
# return True
|
||||
# if len(successful_items) == 0:
|
||||
# return False
|
||||
@@ -193,16 +192,16 @@ 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
|
||||
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:
|
||||
@@ -259,18 +258,12 @@ def read_mails():
|
||||
_all_contact_list = MONGO_STORE_MANAGER.get_all_contacts_to_book()
|
||||
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, _refreshed_successful_items)
|
||||
if is_need_to:
|
||||
MONGO_STORE_MANAGER.save_links_to_validate(url, mail.to_address, _all_contact_list, _item)
|
||||
# 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