From 17fba10d8ffe14bb47ae6389dbb28b012eac1b35 Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Tue, 25 Jul 2023 10:59:48 +0200 Subject: replacing mail_parser by eml_codec, first iteration --- src/mail/mailbox.rs | 8 ++++---- src/mail/mod.rs | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/mail') diff --git a/src/mail/mailbox.rs b/src/mail/mailbox.rs index 445dcfd..4a7d712 100644 --- a/src/mail/mailbox.rs +++ b/src/mail/mailbox.rs @@ -315,10 +315,10 @@ impl MailboxInternal { }, async { // Save mail meta - let mail_root = mail.parsed.root_part(); + let mail_root = mail.parsed.imf; let meta = MailMeta { internaldate: now_msec(), - headers: mail.raw[..mail_root.offset_body].to_vec(), + headers: vec![], message_key: message_key.clone(), rfc822_size: mail.raw.len(), }; @@ -368,10 +368,10 @@ impl MailboxInternal { }, async { // Save mail meta - let mail_root = mail.parsed.root_part(); + let mail_root = mail.parsed.imf; let meta = MailMeta { internaldate: now_msec(), - headers: mail.raw[..mail_root.offset_body].to_vec(), + headers: vec![], //@FIXME we need to put the headers part message_key: message_key.clone(), rfc822_size: mail.raw.len(), }; diff --git a/src/mail/mod.rs b/src/mail/mod.rs index 80c348a..bbe4033 100644 --- a/src/mail/mod.rs +++ b/src/mail/mod.rs @@ -13,7 +13,7 @@ pub mod user; #[allow(clippy::upper_case_acronyms)] pub struct IMF<'a> { raw: &'a [u8], - parsed: mail_parser::Message<'a>, + parsed: eml_codec::part::composite::Message<'a>, } impl<'a> TryFrom<&'a [u8]> for IMF<'a> { @@ -23,7 +23,7 @@ impl<'a> TryFrom<&'a [u8]> for IMF<'a> { eprintln!("---- BEGIN PARSED MESSAGE ----"); let _ = std::io::stderr().write_all(body); eprintln!("---- END PARSED MESSAGE ----"); - let parsed = mail_parser::Message::parse(body).ok_or(())?; + let parsed = eml_codec::parse_message(body).or(Err(()))?.1; Ok(Self { raw: body, parsed }) } } -- cgit v1.2.3