aboutsummaryrefslogtreecommitdiff
path: root/src/imap/attributes.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2024-01-15 07:07:06 +0000
committerQuentin <quentin@dufour.io>2024-01-15 07:07:06 +0000
commit55e26d24a08519ded6a6898453dcd6db287f45c8 (patch)
tree074d9f8dbc161d2aa8f59be26826b40c09d3d658 /src/imap/attributes.rs
parentd49a2355f71fe555a67a815c31800f901a0d0a71 (diff)
parent81bfed3b7df354148f284ed4e3708c1a086d6e58 (diff)
downloadaerogramme-55e26d24a08519ded6a6898453dcd6db287f45c8.tar.gz
aerogramme-55e26d24a08519ded6a6898453dcd6db287f45c8.zip
Merge pull request 'CONDSTORE' (#71) from feat/condstore-try-2 into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/71
Diffstat (limited to 'src/imap/attributes.rs')
-rw-r--r--src/imap/attributes.rs17
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 {