From 1bf5bc17fce25ae28dd64ad46847dde90767eb99 Mon Sep 17 00:00:00 2001 From: PAN Lei Date: Tue, 1 Aug 2023 12:34:32 +0200 Subject: [PATCH] add method to check all contacts' mails --- src/db/mongo_manager.py | 17 +++++++++++++++++ src/mail/mail_refused.py | 2 ++ 2 files changed, 19 insertions(+) diff --git a/src/db/mongo_manager.py b/src/db/mongo_manager.py index 5400fe1..c2e80e2 100644 --- a/src/db/mongo_manager.py +++ b/src/db/mongo_manager.py @@ -15,6 +15,7 @@ MONGO_DB_URL = "mongo.lpaconsulting.fr" CAPTCHA_ERROR_COLLECTION_PREFIX = "CAPTCHA_ERROR_" BLACK_LIST = "BLACK_LIST" ACCEPTED_APPOINTMENT_LIST = "ACCEPTED_APPOINTMENT_LIST" +CONTACT_LIST_TO_BOOK = "CONTACT_LIST_TO_BOOK" EMAIL_LIST = "EMAIL_LIST" DESTINATION_EMAIL_LIST = "DESTINATION_EMAIL_LIST" LINKS_TO_VALIDATE = "LINKS_TO_VALIDATE" @@ -71,6 +72,15 @@ class MongoDbManager: except Exception as Error: self.logger.info(Error) + def upload_contact_list(self, contact_list: list): + + try: + collection_to_use = self.db[CONTACT_LIST_TO_BOOK] + for contact in contact_list: + collection_to_use.insert_one(contact.to_firestore_dict()) + except Exception as Error: + self.logger.info(Error) + def get_all_accepted_appointments(self) -> list: collection_name = ACCEPTED_APPOINTMENT_LIST appointment_list_contacts = [] @@ -190,6 +200,13 @@ class MongoDbManager: result_list.append(ReserveResultPojo.from_firestore_dict(document)) return result_list + def get_all_contact_to_book_list(self) -> list: + result_list = [] + cursor = self.db[CONTACT_LIST_TO_BOOK] + for document in cursor.find(): + result_list.append(ContactPojo.from_firestore_dict(document)) + return result_list + def get_accepted_items_for_one_day(self, day_in_str: str) -> list: collection_name = day_in_str result_list = [] diff --git a/src/mail/mail_refused.py b/src/mail/mail_refused.py index 7c3e835..c7b1ee8 100644 --- a/src/mail/mail_refused.py +++ b/src/mail/mail_refused.py @@ -12,6 +12,7 @@ from src.mail.mail_constants import DOMAIN_163, DOMAIN_YAHOO, DOMAIN_SINA, IMAP_ from src.pojo.mail.mail_pojo import MailPojo REFUSED_SUBJECT_EN = 'Appointment follow up' +REFUSED_SUBJECT_FR = 'Demande de rendez-vous' HERMES_EMAIL = "no-reply@hermes.com" date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014 @@ -51,6 +52,7 @@ class MailRefusedReader(): mail_list = [] print("read mails from {}".format(self.login)) mail_list.extend(self._get_messages_from_folder(imap, REFUSED_SUBJECT_EN)) + mail_list.extend(self._get_messages_from_folder(imap, REFUSED_SUBJECT_FR)) # close the connection and logout imap.close() imap.logout()