From 9644ced794e0c045911fecaa6224cb821a8087cf Mon Sep 17 00:00:00 2001 From: Dimitri Date: Thu, 12 Sep 2024 08:21:28 +0700 Subject: [PATCH] Acknowledgement as replies in email thread --- packages/relayer/src/modules/mail.rs | 4 +++- packages/relayer/src/modules/web_server/rest_api.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/relayer/src/modules/mail.rs b/packages/relayer/src/modules/mail.rs index 88f67140..ab792c39 100644 --- a/packages/relayer/src/modules/mail.rs +++ b/packages/relayer/src/modules/mail.rs @@ -51,6 +51,7 @@ pub enum EmailAuthEvent { email_addr: String, command: String, original_message_id: Option, + original_subject: String, }, NoOp, } @@ -335,6 +336,7 @@ pub async fn handle_email_event(event: EmailAuthEvent) -> Result<(), EmailError> email_addr, command, original_message_id, + original_subject, } => { let body_plain = format!( "Hi {}!\nYour email with the command {} is received.", @@ -342,7 +344,7 @@ pub async fn handle_email_event(event: EmailAuthEvent) -> Result<(), EmailError> ); let render_data = serde_json::json!({"userEmailAddr": email_addr, "request": command}); let body_html = render_html("acknowledgement.html", render_data).await?; - let subject = format!("Acknowledgement"); + let subject = format!("Re: {}", original_subject); let email = EmailMessage { to: email_addr, subject, diff --git a/packages/relayer/src/modules/web_server/rest_api.rs b/packages/relayer/src/modules/web_server/rest_api.rs index 7e39b8b5..f099b5fb 100644 --- a/packages/relayer/src/modules/web_server/rest_api.rs +++ b/packages/relayer/src/modules/web_server/rest_api.rs @@ -440,11 +440,13 @@ fn parse_error_message(error_data: String) -> String { pub async fn receive_email_api_fn(email: String) -> Result<(), ApiError> { let parsed_email = ParsedEmail::new_from_raw_email(&email).await?; let from_addr = parsed_email.get_from_addr()?; + let original_subject = parsed_email.get_subject_all()?; tokio::spawn(async move { match handle_email_event(EmailAuthEvent::Ack { email_addr: from_addr.clone(), command: parsed_email.get_command(false).unwrap_or_default(), original_message_id: parsed_email.get_message_id().ok(), + original_subject, }) .await {