add temp mail
This commit is contained in:
@@ -6,14 +6,13 @@ from builtins import list
|
|||||||
from concurrent.futures import ThreadPoolExecutor
|
from concurrent.futures import ThreadPoolExecutor
|
||||||
from email.header import decode_header
|
from email.header import decode_header
|
||||||
from email.message import Message
|
from email.message import Message
|
||||||
|
|
||||||
from imapclient import IMAPClient
|
from imapclient import IMAPClient
|
||||||
|
|
||||||
from src.db.mirgration.migration_tools import migre_accepted_appointment
|
from src.db.mirgration.migration_tools import migre_accepted_appointment
|
||||||
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
from src.db.mongo_manager import MONGO_STORE_MANAGER
|
||||||
from src.logs.AppLogging import init_logger
|
|
||||||
from src.mail.mail_constants import create_imap, show_folders
|
from src.mail.mail_constants import create_imap, show_folders
|
||||||
from src.notification.AcceptedResultPojo import get_accepted_result_from
|
from src.notification.AcceptedResultPojo import get_accepted_result_from
|
||||||
from src.notification.SignalSender import SignalSender
|
|
||||||
from src.notification.mailer import Mailer
|
from src.notification.mailer import Mailer
|
||||||
from src.pojo.ResultEnum import ResultEnum
|
from src.pojo.ResultEnum import ResultEnum
|
||||||
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
|
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
|
||||||
@@ -71,7 +70,7 @@ class MailConfirmationReader():
|
|||||||
from_address = email_message.get('FROM')
|
from_address = email_message.get('FROM')
|
||||||
subject = email_message.get('subject')
|
subject = email_message.get('subject')
|
||||||
body = ""
|
body = ""
|
||||||
if "no-reply@hermes.com" in from_address:
|
# if "no-reply@hermes.com" in from_address:
|
||||||
for part in email_message.walk():
|
for part in email_message.walk():
|
||||||
print(part.get_content_type())
|
print(part.get_content_type())
|
||||||
if part.get_content_type() == "text/html":
|
if part.get_content_type() == "text/html":
|
||||||
@@ -79,7 +78,7 @@ class MailConfirmationReader():
|
|||||||
elif part.get_content_type() == "text/plain":
|
elif part.get_content_type() == "text/plain":
|
||||||
body = body + part.get_payload()
|
body = body + part.get_payload()
|
||||||
logger.info("mail is {} and subject is {}, body is {}".format(self.login, subject, body))
|
logger.info("mail is {} and subject is {}, body is {}".format(self.login, subject, body))
|
||||||
if CONFIRMATION_SUBJECT_FR in subject or CONFIRMATION_SUBJECT_EN in subject or "Votre_rendez-vous_est_confirm" in subject:
|
if CONFIRMATION_SUBJECT_FR in subject or CONFIRMATION_SUBJECT_EN in subject or "Votre_rendez-vous_est_confirm" in subject or "Votre rendez-vous est confirm" in body:
|
||||||
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
mail = MailPojo(subject=subject, body=body, from_address=from_address)
|
||||||
mail.isImapClient = True
|
mail.isImapClient = True
|
||||||
mail.mail_address = self.login
|
mail.mail_address = self.login
|
||||||
@@ -155,7 +154,7 @@ def accept_appointment_found(accepted_result_list: list):
|
|||||||
for user in _all_register_account:
|
for user in _all_register_account:
|
||||||
if user.mail == result.email:
|
if user.mail == result.email:
|
||||||
result.account_password = user.password
|
result.account_password = user.password
|
||||||
mailer.send_email(result, to_all=True)
|
mailer.send_email(result, to_all=False)
|
||||||
MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message)
|
MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message)
|
||||||
# sginal.send_result(result)
|
# sginal.send_result(result)
|
||||||
|
|
||||||
@@ -172,6 +171,8 @@ def find_confirmation_contacts_for_today():
|
|||||||
for _item in _all_appointments_today:
|
for _item in _all_appointments_today:
|
||||||
for _mail in _all_mail_list:
|
for _mail in _all_mail_list:
|
||||||
if _mail.mail == _item.mail:
|
if _mail.mail == _item.mail:
|
||||||
|
# do not need to scan outlook
|
||||||
|
if "outlook.com" not in _mail.mail:
|
||||||
# if _item.url_validated is True:
|
# if _item.url_validated is True:
|
||||||
_mail_list_to_scan.append(_mail)
|
_mail_list_to_scan.append(_mail)
|
||||||
break
|
break
|
||||||
@@ -180,6 +181,8 @@ def find_confirmation_contacts_for_today():
|
|||||||
|
|
||||||
|
|
||||||
def find_confirmation_contacts_mail_list(mail_list):
|
def find_confirmation_contacts_mail_list(mail_list):
|
||||||
|
# mail_list = [MailAddress("saigecong1990@pissmail.com", "cvExXKOP8oY1D@")]
|
||||||
|
mail_list.append(MailAddress("saigecong1990@pissmail.com", "cvExXKOP8oY1D@"))
|
||||||
mails_messages = []
|
mails_messages = []
|
||||||
# read all the emails
|
# read all the emails
|
||||||
with ThreadPoolExecutor(max_workers=200) as executor:
|
with ThreadPoolExecutor(max_workers=200) as executor:
|
||||||
|
|||||||
Reference in New Issue
Block a user