crabmail

Static HTML email archive viewer in Rust
git clone git://git.alexwennerberg.com/crabmail
Log | Files | Refs | README | LICENSE

commit 44a2575bb643e1a56b1ded2514bd0810db01e1fa
parent 72317b4124beee477e4e0615d247dd53ea1fb9d9
Author: alex wennerberg <alex@alexwennerberg.com>
Date:   Sun, 20 Mar 2022 13:03:34 -0700

Fix date headers

Diffstat:
MCargo.lock | 40+---------------------------------------
MTODO | 4+++-
Msrc/models.rs | 10+++++++++-
3 files changed, 13 insertions(+), 41 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock @@ -9,22 +9,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4361135be9122e0870de935d7c439aef945b9f9ddd4199a553b5270b49c82a27" [[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "num-integer", - "num-traits", -] - -[[package]] name = "crabmail" version = "0.1.0" dependencies = [ @@ -49,10 +33,7 @@ dependencies = [ [[package]] name = "mail-builder" version = "0.1.3" -source = "git+https://github.com/alexwennerberg/mail-builder#f32b7715909d226ea35bd1dee33a6175e9bb623a" -dependencies = [ - "chrono", -] +source = "git+https://github.com/alexwennerberg/mail-builder#f276c3625316cafb5708547b188f62112f64ab27" [[package]] name = "mail-parser" @@ -72,25 +53,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcde141f0a9acabd38860369eeb0d69f1756d19c5948672c211e82e0519edd61" [[package]] -name = "num-integer" -version = "0.1.44" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" -dependencies = [ - "autocfg", - "num-traits", -] - -[[package]] -name = "num-traits" -version = "0.2.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] - -[[package]] name = "once_cell" version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/TODO b/TODO @@ -5,9 +5,11 @@ paginate list home fix docs check for html escape bugz add date to generated string +fix date fmt add "exclude html" flag reference mblaze command, add examples to readme -cut out dependencies in my mailbuilder fork +fix all the build warnings +remove unused Duplicate ID verification: warn on duplicate ID, use first received-date. This is to prevent someone overwriting old emails secretly diff --git a/src/models.rs b/src/models.rs @@ -1,6 +1,7 @@ use crate::config::{Config, Subsection}; use crate::threading::{Msg, ThreadIdx}; use crate::time::Date; +use mail_builder::headers::text::Text; use mail_builder::MessageBuilder; use mail_parser::{Addr, HeaderName, HeaderValue, Message, MessagePart}; use mail_parser::{MimeHeaders, RfcHeader}; @@ -149,7 +150,9 @@ impl StrMessage { } let from = self.from.name.clone().unwrap_or(String::new()); message.from((from.as_str(), self.from.address.as_str())); + // TODO fix to message.to("jane@doe.com"); + message.header("Date", Text::from(self.date.as_str())); // cc if let Some(irt) = &self.in_reply_to { message.in_reply_to(irt.as_str()); @@ -201,7 +204,12 @@ impl StrMessage { _ => &invalid_email, }; let from = MailAddress::from_addr(from); - let date = msg.get_date().unwrap().to_iso8601(); // TODO use date format + let date = msg + .get_rfc_header(RfcHeader::Date) + .and_then(|x| Some(x.get(0).unwrap_or(&Cow::from("")).to_string())) + .unwrap_or(String::new()) + .trim() + .to_owned(); // TODO awkawrd let to = match msg.get_to() { HeaderValue::Address(fr) => vec![MailAddress::from_addr(fr)], HeaderValue::AddressList(fr) => fr.iter().map(|a| MailAddress::from_addr(a)).collect(),