From 9eabb16425dbd262f0c415b16be6cb92d27fa5f7 Mon Sep 17 00:00:00 2001 From: "Rodrigo Rodriguez (Pragmatismo)" Date: Sun, 24 Aug 2025 20:48:52 -0300 Subject: [PATCH] Remove unnecessary wait in emulator flow, update email content type - Removed the 3000 milliseconds wait in on-emulator-sent.bas to streamline the process - Updated the email formatting to use 'text/html; charset=UTF-8' for better content handling in email.rs - Adjusted create_draft to use HTML formatting and replaced texts accordingly, also optimized the email draft saving logic --- src/prompts/business/on-emulator-sent.bas | 2 +- src/services/email.rs | 3 +-- src/services/keywords/create_draft.rs | 22 +++++++++++++--------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/prompts/business/on-emulator-sent.bas b/src/prompts/business/on-emulator-sent.bas index 49107c7..a6ab7d1 100644 --- a/src/prompts/business/on-emulator-sent.bas +++ b/src/prompts/business/on-emulator-sent.bas @@ -8,5 +8,5 @@ FOR EACH item IN items CREATE_DRAFT to, subject, body SET "gb.rob", "id="+ item.id, "ACTION=EMUL_ASKED" - WAIT 3000 + NEXT item diff --git a/src/services/email.rs b/src/services/email.rs index a990998..97a9237 100644 --- a/src/services/email.rs +++ b/src/services/email.rs @@ -245,9 +245,8 @@ pub async fn save_email_draft( .filter(|cc| !cc.is_empty()) .map(|cc| format!("Cc: {}\r\n", cc)) .unwrap_or_default(); - let email_message = format!( - "From: {}\r\nTo: {}\r\n{}Subject: {}\r\nDate: {}\r\n\r\n{}", + "From: {}\r\nTo: {}\r\n{}Subject: {}\r\nDate: {}\r\nContent-Type: text/html; charset=UTF-8\r\n\r\n{}", email_config.username, draft_data.to, cc_header, diff --git a/src/services/keywords/create_draft.rs b/src/services/keywords/create_draft.rs index 8cabf82..eb14054 100644 --- a/src/services/keywords/create_draft.rs +++ b/src/services/keywords/create_draft.rs @@ -38,10 +38,15 @@ async fn execute_create_draft( let get_result = fetch_latest_sent_to(&state.config.clone().unwrap().email, to).await; let email_body = if let Ok(get_result_str) = get_result { if !get_result_str.is_empty() { - let email_separator = "\n\n-------------------------------------------------\n\n"; // Horizontal rule style separator - reply_text.to_string() + email_separator + get_result_str.as_str() + let email_separator = "


"; // Horizontal rule in HTML + let formatted_reply_text = reply_text.to_string(); + let formatted_old_text = get_result_str.replace("\n", "
"); + let fixed_reply_text = formatted_reply_text.replace("FIX", "Fixed"); + format!( + "{}{}{}", + fixed_reply_text, email_separator, formatted_old_text + ) } else { - // Fixed: Use reply_text when get_result_str is empty, not empty string reply_text.to_string() } } else { @@ -56,10 +61,9 @@ async fn execute_create_draft( text: email_body, }; - let save_result = - match save_email_draft(&state.config.clone().unwrap().email, &draft_request).await { - Ok(_) => Ok("Draft saved successfully".to_string()), - Err(e) => Err(e.to_string()), - }; - save_result + let save_result = save_email_draft(&state.config.clone().unwrap().email, &draft_request).await; + match save_result { + Ok(_) => Ok("Draft saved successfully".to_string()), + Err(e) => Err(e.to_string()), + } }