moving all forms to use new logger and email abstraction

This commit is contained in:
Chris Cochrun 2024-11-08 07:14:07 -06:00
parent e8dbb324f3
commit ebaf770d81
7 changed files with 55 additions and 103 deletions

View file

@ -5,6 +5,9 @@ use lettre::{
transport::smtp::authentication::{Credentials, Mechanism},
Message, SmtpTransport, Transport,
};
use tracing::info;
use crate::email::send_email;
#[derive(Debug, MultipartForm, Default)]
struct TeacherForm {
@ -75,7 +78,7 @@ pub async fn teacher_form(MultipartForm(form): MultipartForm<TeacherForm>) -> Ht
.unwrap_or(&Text(String::from("")))
.0
.clone();
log::info!("{first} {last} filled out a teacher form!");
info!("{first} {last} filled out a teacher form!");
let email = markup::new! {
@markup::doctype()
html {
@ -143,21 +146,9 @@ pub async fn teacher_form(MultipartForm(form): MultipartForm<TeacherForm>) -> Ht
.subject(email_subject)
.multipart(multi)
{
let sender = SmtpTransport::relay("mail.tfcconnection.org")
.ok()
.unwrap()
.credentials(Credentials::new(
"no-reply@mail.tfcconnection.org".to_owned(),
"r9f36mNZFtiW4f".to_owned(),
))
.authentication(vec![Mechanism::Plain])
.build();
match sender.send(&m) {
Ok(res) => log::info!("{:?}", res),
Err(e) => log::info!("{e}"),
}
let _ = send_email(m);
} else {
log::info!("Email incorrect");
info!("Email incorrect");
}
HttpResponse::Ok().body("hi")