Skip to content

Commit

Permalink
added member name into email subject and pdf name (#63)
Browse files Browse the repository at this point in the history
We want member's name in email subject and pdf name. It will help with
searching for correct email when processing multiple applications.
Treasurer also needs to upload pdf into drive with in `name_surname.pdf`
format, so we can name it correct way at the server and save treasurer
some time.
  • Loading branch information
Kubik161 authored and ICTGuerrilla committed Jul 8, 2023
1 parent 8d6569d commit b488a34
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions orca/src/processing/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,31 @@ async fn process(
.renderer(&templates::NEW_APPLICATION_NOTICE, "default");
let message_html = config.templates.render(&renderer)?;

// We need member details because we want to customize email subject/pdf name
let member_details = query::query_registration(reg_id).fetch_one(db_pool).await?;

let email_subject = format!(
"New Application - {} {}",
member_details.first_name.as_deref().unwrap_or(""),
member_details.last_name.as_deref().unwrap_or("")
);

let pdf_name = format!(
"{}_{}.pdf",
member_details.first_name.as_deref().unwrap_or(""),
member_details.last_name.as_deref().unwrap_or("")
);

let message = Message::builder()
.from(sender_info.clone())
.reply_to(sender_info)
.to(format!("Notifications <{}>", notification_email).parse()?)
.subject("New Application")
.subject(email_subject)
.multipart(
MultiPart::related()
.singlepart(SinglePart::html(message_html))
.singlepart(
Attachment::new(String::from("application.pdf"))
Attachment::new(String::from(pdf_name))
// This should never fail
// we generate the pdf ourselves so we know it will be valid
.body(pdf_data, "application/pdf".parse().unwrap()),
Expand Down

0 comments on commit b488a34

Please sign in to comment.