Remove unnecessary wait in emulator flow, update email content type
Some checks failed
GBCI / build (push) Has been cancelled
Some checks failed
GBCI / build (push) Has been cancelled
- 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
This commit is contained in:
parent
7e357d278c
commit
9eabb16425
3 changed files with 15 additions and 12 deletions
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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 = "<br><hr><br>"; // Horizontal rule in HTML
|
||||
let formatted_reply_text = reply_text.to_string();
|
||||
let formatted_old_text = get_result_str.replace("\n", "<br>");
|
||||
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()),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue