republish valid cookie

This commit is contained in:
2024-01-15 16:03:12 +01:00
parent d1ffd28b6a
commit 455997a71c
8 changed files with 244 additions and 101 deletions
+8 -4
View File
@@ -7,6 +7,7 @@ import pika
from db.mongo_manager import MONGO_STORE_MANAGER
from models.contact_pojo import ContactPojo
from queue_message.CookiesPublisher import CookiesPublisher
from workers.captcha_result_getter import CaptchaResultGetter, HERMES_REGISTER
from workers.sender import Sender
@@ -66,8 +67,10 @@ def get_valid_csrf() -> str:
class Receiver(threading.Thread):
def __init__(self, sub_contact_list: list):
def __init__(self, sub_contact_list: list, cookiesPublisher: CookiesPublisher):
super().__init__()
self.connection = None
self.cookiesPublisher = cookiesPublisher
self.channel = None
self.valid_csrf = None
self.contact_list = sub_contact_list
@@ -84,21 +87,22 @@ class Receiver(threading.Thread):
def on_message(self, ch, method, properties, body):
print(f" [x] Received {body}")
sender = Sender(body.decode("UTF-8"))
sender = Sender(body.decode("UTF-8"), cookiesPublisher=self.cookiesPublisher)
self.contact_list = filter_contacts(self.contact_list)
# remove already booked contacts
random.shuffle(self.contact_list)
if len(self.contact_list) > 0:
captchaResultGetter = CaptchaResultGetter()
print("contact number is {}".format(len(self.contact_list)))
for con in self.contact_list:
# if not is_already_sent(con):
print(con.mail)
# time.sleep(random.randint(1, 5))
if self.valid_csrf is None:
self.valid_csrf = get_valid_csrf()
self.valid_csrf = captchaResultGetter.get_csrf(body.decode("UTF-8"))
can_continue = sender.send_request(HERMES_REGISTER, con, csrf=self.valid_csrf)
if not can_continue:
print("cannot continue, valid_csrf is " + self.valid_csrf)
print("cannot continue, valid_csrf is " + str(self.valid_csrf))
break
else:
print("can continue, will reset valid_csrf")