diff options
Diffstat (limited to 'src/imap/attributes.rs')
-rw-r--r-- | src/imap/attributes.rs | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/imap/attributes.rs b/src/imap/attributes.rs index cf7cb52..d094f1a 100644 --- a/src/imap/attributes.rs +++ b/src/imap/attributes.rs @@ -1,4 +1,5 @@ use imap_codec::imap_types::fetch::{MacroOrMessageDataItemNames, MessageDataItemName, Section}; +use imap_codec::imap_types::command::FetchModifier; /// Internal decisions based on fetched attributes /// passed by the client @@ -7,7 +8,7 @@ pub struct AttributesProxy { pub attrs: Vec<MessageDataItemName<'static>>, } impl AttributesProxy { - pub fn new(attrs: &MacroOrMessageDataItemNames<'static>, is_uid_fetch: bool) -> Self { + pub fn new(attrs: &MacroOrMessageDataItemNames<'static>, modifiers: &[FetchModifier], is_uid_fetch: bool) -> Self { // Expand macros let mut fetch_attrs = match attrs { MacroOrMessageDataItemNames::Macro(m) => { @@ -31,9 +32,23 @@ impl AttributesProxy { 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 { |