aboutsummaryrefslogtreecommitdiff
path: root/src/imap
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:32:55 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-08 21:32:55 +0100
commit056f8ea14c373b8c0009ed4827a553ac2e27815b (patch)
tree81e3bfd1419feb87f4f44513e4ee3d0e34ecd20e /src/imap
parenta90f425d32af866974eec58b43c02f302ae3376a (diff)
downloadaerogramme-056f8ea14c373b8c0009ed4827a553ac2e27815b.tar.gz
aerogramme-056f8ea14c373b8c0009ed4827a553ac2e27815b.zip
Better choose wether or not a body is required
Diffstat (limited to 'src/imap')
-rw-r--r--src/imap/attributes.rs28
-rw-r--r--src/imap/mail_view.rs5
2 files changed, 21 insertions, 12 deletions
diff --git a/src/imap/attributes.rs b/src/imap/attributes.rs
index 7a55632..8ab891e 100644
--- a/src/imap/attributes.rs
+++ b/src/imap/attributes.rs
@@ -1,4 +1,4 @@
-use imap_codec::imap_types::fetch::{MacroOrMessageDataItemNames, MessageDataItemName};
+use imap_codec::imap_types::fetch::{MacroOrMessageDataItemNames, MessageDataItemName, Section};
/// Internal decisions based on fetched attributes
/// passed by the client
@@ -36,14 +36,26 @@ impl AttributesProxy {
pub fn need_body(&self) -> bool {
self.attrs.iter().any(|x| {
- matches!(
- x,
+ println!("item is: {:?}", x);
+ match x {
MessageDataItemName::Body
- | MessageDataItemName::BodyExt { .. }
- | MessageDataItemName::Rfc822
- | MessageDataItemName::Rfc822Text
- | MessageDataItemName::BodyStructure
- )
+ | MessageDataItemName::Rfc822
+ | MessageDataItemName::Rfc822Text
+ | MessageDataItemName::BodyStructure => true,
+
+ MessageDataItemName::BodyExt {
+ section: Some(section),
+ partial: _,
+ peek: _,
+ } => match section {
+ Section::Header(None)
+ | Section::HeaderFields(None, _)
+ | Section::HeaderFieldsNot(None, _) => false,
+ _ => true,
+ },
+ MessageDataItemName::BodyExt { .. } => true,
+ _ => false,
+ }
})
}
}
diff --git a/src/imap/mail_view.rs b/src/imap/mail_view.rs
index a593b1a..eeb6b4b 100644
--- a/src/imap/mail_view.rs
+++ b/src/imap/mail_view.rs
@@ -32,10 +32,7 @@ pub struct MailView<'a> {
}
impl<'a> MailView<'a> {
- pub fn new(
- query_result: &'a QueryResult,
- in_idx: &'a MailIndex<'a>,
- ) -> Result<MailView<'a>> {
+ pub fn new(query_result: &'a QueryResult, in_idx: &'a MailIndex<'a>) -> Result<MailView<'a>> {
Ok(Self {
in_idx,
query_result,