read mail after request

This commit is contained in:
2024-03-21 14:55:17 +01:00
parent 67b6a181cb
commit dead188a69
9 changed files with 471 additions and 6 deletions
+38
View File
@@ -7,6 +7,7 @@ from pymongo import MongoClient
from models.LinkPojo import LinkPojo
from models.ReserveResultPojo import ReserveResultPojo
from models.contact_pojo import ContactPojo
from models.mail_pojo import MailAddress
MONGO_DB_URL = "mongo.lpaconsulting.fr"
CAPTCHA_ERROR_COLLECTION_PREFIX = "CAPTCHA_ERROR_"
@@ -72,6 +73,43 @@ class MongoDbManager:
result_list.append(ContactPojo.from_firestore_dict(document))
return result_list
def save_links_to_validate(self, link: str, mail_address: str, _all_contact_list: list):
collection_to_use = self.db[LINKS_TO_VALIDATE]
updated_at = time.strftime("%H:%M:%S", time.localtime())
_ip_country = "FR"
# find ip_country info
for _contact in _all_contact_list:
if _contact.mail == mail_address:
_ip_country = _contact.ip_country
if len(mail_address) > 0:
collection_to_use.replace_one(filter={'_id': mail_address, }, replacement={
u'url': link,
u'email': mail_address,
u'ip_country': _ip_country,
"updated_at": updated_at
},
upsert=True)
else:
collection_to_use.replace_one(filter={'_id': link, }, replacement={
u'url': link,
u'ip_country': _ip_country,
"updated_at": updated_at
},
upsert=True)
def get_destination_emails(self) -> list:
collection_name = DESTINATION_EMAIL_LIST
email_list = []
try:
collection_to_use = self.db[collection_name]
for document in collection_to_use.find():
email_list.append(MailAddress.from_firestore_dict(document))
except Exception as error:
self.logger.info(error)
print(error)
return email_list
def get_links_to_validate(self) -> list:
collection_name = LINKS_TO_VALIDATE
link_list = []