add back header fields

This commit is contained in:
Quentin 2023-09-21 11:27:33 +02:00
parent b32bb6071a
commit 1fb9970502
Signed by: quentin
GPG key ID: E9602264D639FF68
2 changed files with 16 additions and 10 deletions

2
Cargo.lock generated
View file

@ -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",

View file

@ -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 {