diff --git a/CHANGELOG.md b/CHANGELOG.md index ffb20e4..d461d5f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Some emojis break the table layout [#300] +- Bad sender and date in reply and forward template [#321] ## [0.5.7] - 2022-03-01 diff --git a/src/msg/msg_entity.rs b/src/msg/msg_entity.rs index 3fa4483..6c2be35 100644 --- a/src/msg/msg_entity.rs +++ b/src/msg/msg_entity.rs @@ -3,7 +3,7 @@ use anyhow::{anyhow, Context, Error, Result}; use chrono::{DateTime, FixedOffset}; use html_escape; use lettre::message::{header::ContentType, Attachment, MultiPart, SinglePart}; -use log::{debug, info, trace}; +use log::{debug, info, trace, warn}; use regex::Regex; use std::{collections::HashSet, convert::TryInto, env::temp_dir, fmt::Debug, fs, path::PathBuf}; use uuid::Uuid; @@ -170,9 +170,6 @@ impl Msg { // In-Reply-To self.in_reply_to = self.message_id.to_owned(); - // From - self.from = Some(vec![account_addr.clone()].into()); - // To let addrs = self .reply_to @@ -198,11 +195,6 @@ impl Msg { self.bcc = None; } - // Subject - if !self.subject.starts_with("Re:") { - self.subject = format!("Re: {}", self.subject); - } - // Body let plain_content = { let date = self @@ -236,6 +228,14 @@ impl Msg { self.parts = Parts(vec![Part::new_text_plain(plain_content)]); + // Subject + if !self.subject.starts_with("Re:") { + self.subject = format!("Re: {}", self.subject); + } + + // From + self.from = Some(vec![account_addr.clone()].into()); + Ok(self) } @@ -648,6 +648,16 @@ impl Msg { "subject" => { msg.subject = val; } + "date" => { + msg.date = DateTime::parse_from_rfc2822( + val.split_at(val.find(" (").unwrap_or_else(|| val.len())).0, + ) + .map_err(|err| { + warn!("cannot parse message date {:?}, skipping it", val); + err + }) + .ok(); + } "from" => { msg.from = from_slice_to_addrs(val) .context(format!("cannot parse header {:?}", key))?