send confirmation info by signal

This commit is contained in:
2023-10-25 18:35:27 +02:00
parent 2ff4e1fd8e
commit cf7155f9fb
5 changed files with 57 additions and 13 deletions
Regular → Executable
View File
+4 -9
View File
@@ -13,12 +13,6 @@ class MailAddressValidator():
self.login = login
self.password = password
@staticmethod
def show_folders(imap):
for i in imap.list()[1]:
l = i.decode().split(' "/" ')
print(l[0] + " = " + l[1])
def is_valid_email_address(self) -> bool:
# authenticate
imap = create_imap(self.login)
@@ -66,9 +60,10 @@ def find_and_update_invalid_emails(mail_list):
if __name__ == '__main__':
# remove_invalid_email()
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
remove_invalid_email()
# mail_list = MONGO_STORE_MANAGER.get_destination_emails()
# excel_reader = ExcelHelper()
# mail_list = excel_reader.read_mails_and_pwd(file_name="/Users/lpan/Downloads/hotmail_list.xlsx")
# print(email_list)
find_and_update_invalid_emails(mail_list)
# find_and_update_invalid_emails(mail_list)
Regular → Executable
+9 -4
View File
@@ -11,13 +11,14 @@ from src.db.mirgration.migration_tools import migre_accepted_appointment
from src.db.mongo_manager import MONGO_STORE_MANAGER
from src.mail.mail_constants import create_imap, show_folders
from src.notification.AcceptedResultPojo import get_accepted_result_from
from src.notification.SignalSender import SignalSender
from src.notification.mailer import Mailer
from src.pojo.ResultEnum import ResultEnum
from src.pojo.mail.mail_pojo import MailPojo
from src.pojo.mail.mail_pojo import MailPojo, MailAddress
from src.utils.excel_reader import ExcelHelper
CONFIRMATION_SUBJECT_FR = 'Votre rendez-vous est'
CONFIRMATION_SUBJECT_EN = 'appointment is confirmed'
CONFIRMATION_SUBJECT_FR = 'rendez-vous est'
CONFIRMATION_SUBJECT_EN = 'confirmed'
HERMES_EMAIL = "no-reply@hermes.com"
date_format = "%d-%b-%Y" # DD-Mon-YYYY e.g., 3-Mar-2014
@@ -145,10 +146,13 @@ def clean(text):
def accept_appointment_found(accepted_result_list: list):
mailer = Mailer()
sginal = SignalSender()
print(accepted_result_list)
for reserve in accepted_result_list:
mailer.send_email(get_accepted_result_from(reserve, MONGO_STORE_MANAGER), to_all=True)
result = get_accepted_result_from(reserve, MONGO_STORE_MANAGER)
mailer.send_email(result, to_all=False)
MONGO_STORE_MANAGER.update_reserve_result(reserve.id, ResultEnum.ACCEPTED, reserve.message)
sginal.send_result(result)
if len(accepted_result_list) > 0:
migre_accepted_appointment(str(datetime.date.today()))
@@ -156,6 +160,7 @@ def accept_appointment_found(accepted_result_list: list):
def read_mails_and_find_confirmation_contacts():
mail_list = MONGO_STORE_MANAGER.get_destination_emails()
mail_list.reverse()
# excel_reader = ExcelHelper()
# mail_list =excel_reader.read_email_pojo(file_name="/Users/lpan/Desktop/hotmail_list.xlsx")
# mail_address3 = MailAddress(mail="taibenchragu1978@onet.pl", password="2J)kyfNgyOZ")
+32
View File
@@ -0,0 +1,32 @@
import requests
from mako.template import Template
from src import config
from src.notification.AcceptedResultPojo import AcceptedResultPojo
class SignalSender:
def __init__(self):
self.group = "group.NjVhb1NrZU43TytWcTV6YUZkQVZjMmhGYUorK0pWUWJOaGhvS1JUMVYwbz0="
def send_message(self, msg):
x = requests.post("http://appointment.lpaconsulting.fr:10086/v2/send", json=
{"message": msg, "number": "+33768562195",
"recipients": ["group.NjVhb1NrZU43TytWcTV6YUZkQVZjMmhGYUorK0pWUWJOaGhvS1JUMVYwbz0="]}
)
print(x.text)
def send_result(self, result: AcceptedResultPojo):
mytemplate = Template(filename=config.ROOT_DIR + "/templates/signal_results.html")
msg = mytemplate.render(result=result)
self.send_message(msg=msg)
if __name__ == '__main__':
acceptedResultPojo = AcceptedResultPojo(msg="测序<br>测试",
url="https://rendezvousparis.hermes.com/client/register/AQ57C9",
slot_position="", sim_position="", passport="test", email="test@test.com",
name="test test", phone="0649614591", ccid="", created_at="",
validated_at="")
SignalSender().send_result(acceptedResultPojo)
+12
View File
@@ -0,0 +1,12 @@
姓名:${result.name}
电话: ${result.phone}
邮件: ${result.email}, 密码: ${result.mail_password} (用网易邮箱大师登录)
护照: ${result.passport}
约会 url: ${result.url}
邮件内容: ${result.message}