Skip to content

Commit

Permalink
Acknowledgement as replies in email thread
Browse files Browse the repository at this point in the history
  • Loading branch information
DimiDumo committed Sep 13, 2024
1 parent 379f10a commit 7ea7e42
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 3 additions & 1 deletion packages/relayer/src/modules/mail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ pub enum EmailAuthEvent {
email_addr: String,
command: String,
original_message_id: Option<String>,
original_subject: String,
},
NoOp,
}
Expand Down Expand Up @@ -335,14 +336,15 @@ 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.",
email_addr, command
);
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,
Expand Down
2 changes: 2 additions & 0 deletions packages/relayer/src/modules/web_server/rest_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down

0 comments on commit 7ea7e42

Please sign in to comment.