do not read email for successful requests

This commit is contained in:
2024-03-29 16:03:42 +01:00
parent e08483fe94
commit 5dd90359a2
9 changed files with 171 additions and 17 deletions
+16 -1
View File
@@ -34,6 +34,7 @@ def is_already_sent(contact: ContactPojo) -> bool:
def filter_contacts(_contact_list: list, provided_list=[]) -> list:
already_sent_contacts = MONGO_STORE_MANAGER.get_all_successful_items_for_day()
already_sent_contacts.extend(provided_list)
_link_to_validate_list = MONGO_STORE_MANAGER.get_links_to_validate()
_contact_list_to_book = []
for contact in _contact_list:
_to_add = True
@@ -44,6 +45,11 @@ def filter_contacts(_contact_list: list, provided_list=[]) -> list:
else:
if contact.mail == booked.mail:
_to_add = False
# 如果已经收到链接了,就不要再请求
for link_to_validate in _link_to_validate_list:
if contact.mail == link_to_validate.email:
print("{}: link already received".format(contact.mail))
_to_add = False
if _to_add:
_contact_list_to_book.append(contact)
@@ -127,7 +133,7 @@ class AppointmentRequestSender(threading.Thread):
_new_cookies = captchaResultGetter.get_valid_ch_cookie(sender.proxy_to_use, js_data,
old_valid_cookie=_received_cookies)
if _new_cookies is not None:
# self.logger.info("new cookie is " + _new_cookies)
self.logger.info("new cookie is " + _new_cookies)
time.sleep(random.randint(1, 3))
# m_s_c = f.scroll
m_s_c = random.randint(0, 3)
@@ -160,6 +166,14 @@ class AppointmentRequestSender(threading.Thread):
time.sleep(random.randint(1, 3))
self.already_tried_contact_list.append(con)
can_continue = sender.send_request(HERMES_REGISTER, js_data, con, csrf=self.valid_csrf)
if can_continue == RequestResult.SUCCESS:
# 让服务器读取成功的约会
try:
self.logger.info("try to remove success contact from list to retrieve mails")
self.list_to_retrieve_mails.remove(con)
except Exception as e:
self.logger.info("exception while remove success contact from list to retrieve mails")
print(e)
else:
can_continue = RequestResult.COOKIES_ERROR
else:
@@ -196,6 +210,7 @@ class AppointmentRequestSender(threading.Thread):
def retreive_invalidate_urls(self):
if not self.already_read_emails:
self.logger.info("will retreive_invalidate_urls")
time.sleep(30)
_mail_list = MONGO_STORE_MANAGER.get_destination_emails()
_mail_list_filtred = []
for mail in _mail_list: