diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-05-29 10:14:51 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-05-29 10:14:51 +0200 |
commit | b9ce5886033677f6c65a4b873e17574fdb8df31d (patch) | |
tree | 9ed1d721361027d7d6fef0ecad65d7e1b74a7ddb /src/imap/attributes.rs | |
parent | 0dcf69f180f5a7b71b6ad2ac67e4cdd81e5154f1 (diff) | |
parent | 5954de6efbb040b8b47daf0c7663a60f3db1da6e (diff) | |
download | aerogramme-b9ce5886033677f6c65a4b873e17574fdb8df31d.tar.gz aerogramme-b9ce5886033677f6c65a4b873e17574fdb8df31d.zip |
Merge branch 'caldav'
Diffstat (limited to 'src/imap/attributes.rs')
-rw-r--r-- | src/imap/attributes.rs | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/src/imap/attributes.rs b/src/imap/attributes.rs deleted file mode 100644 index 89446a8..0000000 --- a/src/imap/attributes.rs +++ /dev/null @@ -1,77 +0,0 @@ -use imap_codec::imap_types::command::FetchModifier; -use imap_codec::imap_types::fetch::{MacroOrMessageDataItemNames, MessageDataItemName, Section}; - -/// Internal decisions based on fetched attributes -/// passed by the client - -pub struct AttributesProxy { - pub attrs: Vec<MessageDataItemName<'static>>, -} -impl AttributesProxy { - pub fn new( - attrs: &MacroOrMessageDataItemNames<'static>, - modifiers: &[FetchModifier], - is_uid_fetch: bool, - ) -> Self { - // Expand macros - let mut fetch_attrs = match attrs { - MacroOrMessageDataItemNames::Macro(m) => { - use imap_codec::imap_types::fetch::Macro; - use MessageDataItemName::*; - match m { - Macro::All => vec![Flags, InternalDate, Rfc822Size, Envelope], - Macro::Fast => vec![Flags, InternalDate, Rfc822Size], - Macro::Full => vec![Flags, InternalDate, Rfc822Size, Envelope, Body], - _ => { - tracing::error!("unimplemented macro"); - vec![] - } - } - } - MacroOrMessageDataItemNames::MessageDataItemNames(a) => a.clone(), - }; - - // Handle uids - if is_uid_fetch && !fetch_attrs.contains(&MessageDataItemName::Uid) { - fetch_attrs.push(MessageDataItemName::Uid); - } - - // Handle inferred MODSEQ tag - let is_changed_since = modifiers - .iter() - .any(|m| matches!(m, FetchModifier::ChangedSince(..))); - if is_changed_since && !fetch_attrs.contains(&MessageDataItemName::ModSeq) { - fetch_attrs.push(MessageDataItemName::ModSeq); - } - - Self { attrs: fetch_attrs } - } - - pub fn is_enabling_condstore(&self) -> bool { - self.attrs - .iter() - .any(|x| matches!(x, MessageDataItemName::ModSeq)) - } - - pub fn need_body(&self) -> bool { - self.attrs.iter().any(|x| match x { - MessageDataItemName::Body - | 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, - }) - } -} |