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

@ -10,6 +10,7 @@ use lettre::{
use maud::html;
use maud::DOCTYPE;
use reqwest::{Client, Error};
use tracing::info;
use crate::email::send_email;
@ -45,7 +46,7 @@ struct CampForm {
#[post("/camp-form")]
pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResponse {
log::info!("a new form");
info!("a new form");
let first = form
.first_name
.as_ref()
@ -154,9 +155,9 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
.clone();
let reg = registration.clone();
log::info!("Sending post to database");
info!("Sending post to database");
log::info!("{first} {last} signed up for camp!");
info!("{first} {last} signed up for camp!");
let email = html! {
(DOCTYPE)
meta charset="utf-8";
@ -262,17 +263,17 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
{
let _ = send_email(m);
} else {
log::info!("Email incorrect");
info!("Email incorrect");
}
match store_camp_form(form).await {
Ok(_) => log::info!("Successfully posted to nextcloud tables"),
Ok(_) => info!("Successfully posted to nextcloud tables"),
Err(e) => log::error!("Error in posting camp data: {:?}", e),
}
match health.as_str() {
"now" => {
log::info!("Sending them to fill out the health form");
info!("Sending them to fill out the health form");
HttpResponse::Ok()
.insert_header(("Access-Control-Expose-Headers", "*"))
.insert_header((
@ -286,7 +287,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
}
"later" => match reg.as_str() {
"now" => {
log::info!("Sending them to pay for registration now");
info!("Sending them to pay for registration now");
HttpResponse::Ok()
.insert_header(("Access-Control-Expose-Headers", "*"))
.insert_header((
@ -296,7 +297,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
.finish()
}
"full" => {
log::info!("Sending them to pay for the full registration now");
info!("Sending them to pay for the full registration now");
HttpResponse::Ok()
.insert_header(("Access-Control-Expose-Headers", "*"))
.insert_header((
@ -306,7 +307,7 @@ pub async fn camp_form(MultipartForm(form): MultipartForm<CampForm>) -> HttpResp
.finish()
}
"later" => {
log::info!("{} would like to pay later", full_name);
info!("{} would like to pay later", full_name);
let html = html! {
div class="mt-8" {
h2 {