diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-09-21 11:27:33 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2023-09-21 11:27:33 +0200 |
commit | 1fb9970502ed654d99ab41dd8d1cb5c09ea91c02 (patch) | |
tree | 2ae43aa32c8a533cfee886b06e0cebd441470ad2 | |
parent | b32bb6071a58c94dd014c53de989bff3e4cc166b (diff) | |
download | aerogramme-1fb9970502ed654d99ab41dd8d1cb5c09ea91c02.tar.gz aerogramme-1fb9970502ed654d99ab41dd8d1cb5c09ea91c02.zip |
add back header fields
-rw-r--r-- | Cargo.lock | 2 | ||||
-rw-r--r-- | src/imap/mailbox_view.rs | 24 |
2 files changed, 16 insertions, 10 deletions
@@ -844,7 +844,7 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "eml-codec" version = "0.1.2" -source = "git+https://git.deuxfleurs.fr/Deuxfleurs/eml-codec.git?branch=main#5cff5510acc2c414b74419e0ee636d5ab249036b" +source = "git+https://git.deuxfleurs.fr/Deuxfleurs/eml-codec.git?branch=main#a7bd3c475a58e42b86c163ec075ce01ddae7e60a" dependencies = [ "base64 0.21.2", "chrono", diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs index 72d39af..d04fabf 100644 --- a/src/imap/mailbox_view.rs +++ b/src/imap/mailbox_view.rs @@ -18,6 +18,7 @@ use imap_codec::types::flag::{Flag, StoreResponse, StoreType}; use imap_codec::types::response::{Code, Data, MessageAttribute, Status}; use imap_codec::types::sequence::{self, SequenceSet}; use eml_codec::{ + header, imf, part::{AnyPart, composite::Message}, mime::r#type::Deductible, @@ -889,8 +890,7 @@ fn get_message_section<'a>( Some( FetchSection::HeaderFields(part, fields) | FetchSection::HeaderFieldsNot(part, fields), ) => { - todo!(); - /*let invert = matches!(section, Some(FetchSection::HeaderFieldsNot(_, _))); + let invert = matches!(section, Some(FetchSection::HeaderFieldsNot(_, _))); let fields = fields .iter() .map(|x| match x { @@ -900,26 +900,32 @@ fn get_message_section<'a>( }) .collect::<Vec<_>>(); - map_subpart_msg( - parsed, + + map_subpart( + parsed.child.as_ref(), part.as_ref().map(|p| p.0.as_slice()).unwrap_or(&[]), |part_msg| { let mut ret = vec![]; - for (hn, hv) in part_msg.headers_raw() { + for f in &part_msg.mime().kv { + let (k, v) = match f { + header::Field::Good(header::Kv2(k, v)) => (k, v), + _ => continue, + }; if fields .as_slice() .iter() - .any(|x| (*x == hn.as_bytes()) ^ invert) + .any(|x| (x == k) ^ invert) { - ret.extend(hn.as_bytes()); + ret.extend(*k); ret.extend(b": "); - ret.extend(hv.as_bytes()); + ret.extend(*v); + ret.extend(b"\r\n"); } } ret.extend(b"\r\n"); Ok(ret.into()) }, - )*/ + ) } Some(FetchSection::Part(part)) => map_subpart(parsed.child.as_ref(), part.0.as_slice(), |part| { let bytes = match &part { |