diff --git a/mail/lan_mail_helper.py b/mail/lan_mail_helper.py new file mode 100644 index 0000000..db5a571 --- /dev/null +++ b/mail/lan_mail_helper.py @@ -0,0 +1,74 @@ +import time + +import requests + +from db.mongo_manager import MONGO_STORE_MANAGER + +host = "https://authhk.bhdata.com:30015/bhmailer?uid=482391396&sign=32d7748da00047b9a1054c81a5750365" + +HERMES_EMAIL = "no-reply@hermes.com" + + +def get_api_info(): + _time = str(int(time.time() * 1000)) + _api_info = host + "&act=getApiInfo&t=" + _time + print(_api_info) + res = requests.get(_api_info, verify=False) + print(res.text) + + +def get_mail(mail: str): + _time = str(int(time.time() * 1000)) + _hermes_mail = "Votre demande de rendez-vous" + _api_info = host + "&act=getMail&email={}&title={}&t={}".format(mail, _hermes_mail, _time) + print(_api_info) + res = requests.get(_api_info, verify=False) + print(res.text) + + +def check_mail(mail: str): + print("check_mail called for {}".format(mail)) + _time = str(int(time.time() * 1000)) + _hermes_mail = HERMES_EMAIL + _api_info = host + "&act=checkMail&email={}&from={}&t={}".format(mail, _hermes_mail, _time) + print(_api_info) + res = requests.get(_api_info, verify=False) + print(res.text) + + +def get_account(mail: str): + _time = str(int(time.time() * 1000)) + _api_info = host + "&act=getAccount&email={}&t={}".format(mail, _time) + print(_api_info) + res = requests.get(_api_info, verify=False) + print(res.text) + + +def filter_mail_with_links(_mail_list_to_filter): + _new_mail_list = [] + _link_to_validate_list = MONGO_STORE_MANAGER.get_links_to_validate() + for _mail in _mail_list_to_filter: + _to_add = True + for _link in _link_to_validate_list: + if _link.email == _mail: + _to_add = False + if _to_add: + _new_mail_list.append(_mail) + return _new_mail_list + + +def get_mail_list_to_check(): + successful_items = MONGO_STORE_MANAGER.get_all_successful_items_for_day() + _mail_list = [] + for _item in successful_items: + if _item.url_validated is None or _item.url_validated != True: + _mail_list.append(_item.mail) + return _mail_list + + +if __name__ == '__main__': + _mail_list_before_filter = get_mail_list_to_check() + _mails = filter_mail_with_links(_mail_list_before_filter) + for _mail in _mails: + if "outlook.com" in _mail or "hotmail.com" in _mail: + check_mail(_mail) diff --git a/mail/mail_reader_all_contacts.py b/mail/mail_reader_all_contacts.py index bcf2869..2236488 100755 --- a/mail/mail_reader_all_contacts.py +++ b/mail/mail_reader_all_contacts.py @@ -243,6 +243,7 @@ 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 + mail_list.append(MailAddress("saigecong1990@pissmail.com", "cvExXKOP8oY1D@")) 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() @@ -278,7 +279,7 @@ if __name__ == '__main__': # file_name="/Users/rdv/Desktop/contact_list_not_used_contacts.xlsx") # file_name="/Users/lpan/Desktop/contact_list_not_used_contacts.xlsx") # file_name="/Users/rdv/Desktop/real_name_contacts_100_hotmail.xlsx") - file_name="/Users/rdv/Desktop/contact_list_2025-06-23.xlsx") + file_name="/Users/lpan/Desktop/contact_list_2025-06-27.xlsx") # file_name="/Users/rdv/Desktop/contact_list_all_studio.xlsx") # file_name="/Users/rdv/Desktop/contact_list_all_studo_gmx_us.xlsx") # file_name="/Users/rdv/Desktop/contact_list_2025-05-24.xlsx") diff --git a/queue_message/appointmentrequestsender.py b/queue_message/appointmentrequestsender.py index 4492d50..0150510 100644 --- a/queue_message/appointmentrequestsender.py +++ b/queue_message/appointmentrequestsender.py @@ -7,6 +7,7 @@ import time import pika from db.mongo_manager import MONGO_STORE_MANAGER +from mail.lan_mail_helper import check_mail from mail.mail_reader_all_contacts import find_links_to_validate_from_mail_list from models.ReserveResultPojo import ReserveResultPojo from models.contact_pojo import ContactPojo @@ -62,6 +63,13 @@ def is_open(): return is_time_between(datetime.time(10, 30), datetime.time(19, 00)) +def check_ms_mails(_mail_list_filtered): + print("check_ms_mails() called.") + for _mail in _mail_list_filtered: + if "outlook.com" in _mail.mail or "hotmail.com" in _mail.mail: + check_mail(_mail.mail) + + class AppointmentRequestSender(threading.Thread): def __init__(self, sub_contact_list: list, logger, cookiesPublisher: CookiesPublisher, bakeUpCookiesPublisher: CookiesPublisher, @@ -252,6 +260,7 @@ class AppointmentRequestSender(threading.Thread): self.logger.info("will get mail from " + mail.mail) _mail_list_filtered.append(mail) self.logger.info("will call find_links_to_validate_from_mail_list, size = " + str(len(_mail_list_filtered))) + check_ms_mails(_mail_list_filtered) find_links_to_validate_from_mail_list(_mail_list_filtered, self.logger) self.already_read_emails = True else: diff --git a/request_sender_test.py b/request_sender_test.py index 3f423e0..5a7cde3 100644 --- a/request_sender_test.py +++ b/request_sender_test.py @@ -10,9 +10,7 @@ from models.contact_pojo import ContactPojo from queue_message.CookiesPublisher import CookiesPublisher, SHARED_OBJECT, TEST_QUEUE, MORNING_DATA_CACHE, \ MORNING_DATA_CACHE_2, MORNING_DATA_CACHE_BAK from queue_message.appointmentrequestsender import AppointmentRequestSender -from utiles import is_time_between from utils.AppLogging import init_logger -from workers.proxies_constants import MOBILE_PROXY_LIST_FR def is_already_sent(contact: ContactPojo) -> bool: @@ -103,6 +101,7 @@ if __name__ == '__main__': # '~/Desktop/contact_list_2024-05-21.xlsx', # '~/Desktop/15_05_to_test.xlsx'] # file_list = ['~/Desktop/15_05_to_test.xlsx', '~/Desktop/16_05_to_test.xlsx'] - file_list = ['~/Desktop/contact_list_2025-06-09_2.xlsx'] - send_request_for_file_list(file_list=file_list, thread_number=10, + # file_list = ['~/Desktop/contact_list_2025-06-24.xlsx'] + file_list = ['~/Desktop/real_name_contacts_100_27_06.xlsx'] + send_request_for_file_list(file_list=file_list, thread_number=2, data_queue_name=MORNING_DATA_CACHE, stop_at_hour=19, stop_at_mins=50) diff --git a/scheduler_test.py b/scheduler_test.py index fb3fa0b..0ca45aa 100644 --- a/scheduler_test.py +++ b/scheduler_test.py @@ -6,8 +6,8 @@ from request_sender_test import send_request_for_file_list def start_book_appointment(): - file_list = ['~/Desktop/contact_list_2025-06-09_2.xlsx'] - send_request_for_file_list(file_list=file_list, thread_number=30, + file_list = ['~/Desktop/contact_list_2025-06-27.xlsx'] + send_request_for_file_list(file_list=file_list, thread_number=50, data_queue_name=MORNING_DATA_CACHE, stop_at_hour=11, stop_at_mins=20)