need to test read confirmation mails
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from src.discord_helper import send_message
|
|
||||||
from src.mail.mail_confirmation import read_mails_and_find_confirmation_contacts
|
from src.mail.mail_confirmation import read_mails_and_find_confirmation_contacts
|
||||||
from src.pojo import ReserveResultPojo
|
from src.pojo import ReserveResultPojo
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ def create_message_from_item(item: ReserveResultPojo):
|
|||||||
def main():
|
def main():
|
||||||
# initialize discord
|
# initialize discord
|
||||||
print("init discord done")
|
print("init discord done")
|
||||||
_accepted_appointments = read_mails_and_find_confirmation_contacts()
|
_accepted_appointments = read_mails_and_find_confirmation_contacts(mode='gmx_only')
|
||||||
# for item in _accepted_appointments:
|
# for item in _accepted_appointments:
|
||||||
# send_message(create_message_from_item(item))
|
# send_message(create_message_from_item(item))
|
||||||
|
|
||||||
|
|||||||
@@ -22,12 +22,12 @@ import os
|
|||||||
import re
|
import re
|
||||||
import socket
|
import socket
|
||||||
import ssl
|
import ssl
|
||||||
from dataclasses import dataclass, field
|
import sys
|
||||||
|
from dataclasses import dataclass
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
from typing import List, Optional, Tuple
|
from typing import List, Optional, Tuple
|
||||||
|
|
||||||
import socks
|
import socks
|
||||||
import sys
|
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
from imapclient import IMAPClient
|
from imapclient import IMAPClient
|
||||||
|
|
||||||
@@ -138,7 +138,6 @@ class MailResult:
|
|||||||
from_address: str
|
from_address: str
|
||||||
to_address: str
|
to_address: str
|
||||||
body: str
|
body: str
|
||||||
validation_urls: List[str] = field(default_factory=list)
|
|
||||||
|
|
||||||
|
|
||||||
# ──────────────────────────────────────────────────────────────
|
# ──────────────────────────────────────────────────────────────
|
||||||
@@ -458,26 +457,23 @@ class ProxyMailReader:
|
|||||||
# Filtrer : on ne garde que les emails correspondant aux sujets/expéditeurs configurés
|
# Filtrer : on ne garde que les emails correspondant aux sujets/expéditeurs configurés
|
||||||
is_validation = (
|
is_validation = (
|
||||||
any(s in subject for s in self._subjects)
|
any(s in subject for s in self._subjects)
|
||||||
or any(addr in from_addr.lower() for addr in self._from_addresses)
|
|
||||||
)
|
)
|
||||||
if not is_validation:
|
if not is_validation:
|
||||||
continue
|
continue
|
||||||
|
|
||||||
body = extract_body(em)
|
body = extract_body(em)
|
||||||
urls = find_validation_urls(body)
|
|
||||||
|
|
||||||
result = MailResult(
|
result = MailResult(
|
||||||
account=self.account.login,
|
account=self.account.login,
|
||||||
subject=subject,
|
subject=subject,
|
||||||
from_address=from_addr,
|
from_address=from_addr,
|
||||||
to_address=to_addr,
|
to_address=to_addr,
|
||||||
body=body,
|
body=body
|
||||||
validation_urls=urls,
|
|
||||||
)
|
)
|
||||||
results.append(result)
|
results.append(result)
|
||||||
logger.info(
|
logger.info(
|
||||||
"[%s] Email de validation trouvé (uid=%s) — URLs : %s",
|
"[%s] Email trouvé (uid=%s) — URLs : %s",
|
||||||
self.account.login, uid, urls or "aucune",
|
self.account.login, uid
|
||||||
)
|
)
|
||||||
except Exception as exc:
|
except Exception as exc:
|
||||||
logger.warning(
|
logger.warning(
|
||||||
|
|||||||
@@ -253,7 +253,7 @@ def find_confirmation_contacts_mail_list(mail_list, subjects: list = None):
|
|||||||
return accepted_appointment_list
|
return accepted_appointment_list
|
||||||
|
|
||||||
|
|
||||||
def read_mails_and_find_confirmation_contacts(all_mails=False, mode: str = 'default', subjects: list = None):
|
def read_mails_and_find_confirmation_contacts(all_mails=False, mode: str = 'default', subjects: list = [CONFIRMATION_SUBJECT_FR, CONFIRMATION_SUBJECT_EN]):
|
||||||
if all_mails:
|
if all_mails:
|
||||||
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user