aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imap/attributes.rs6
-rw-r--r--src/imap/command/examined.rs21
-rw-r--r--src/imap/command/selected.rs21
-rw-r--r--src/imap/mailbox_view.rs4
4 files changed, 34 insertions, 18 deletions
diff --git a/src/imap/attributes.rs b/src/imap/attributes.rs
index cf7cb52..6cf52b5 100644
--- a/src/imap/attributes.rs
+++ b/src/imap/attributes.rs
@@ -34,6 +34,12 @@ impl AttributesProxy {
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 {
diff --git a/src/imap/command/examined.rs b/src/imap/command/examined.rs
index 4767340..ef5cecc 100644
--- a/src/imap/command/examined.rs
+++ b/src/imap/command/examined.rs
@@ -91,14 +91,19 @@ impl<'a> ExaminedContext<'a> {
uid: &bool,
) -> Result<(Response<'static>, flow::Transition)> {
match self.mailbox.fetch(sequence_set, attributes, uid).await {
- Ok(resp) => Ok((
- Response::build()
- .to_req(self.req)
- .message("FETCH completed")
- .set_body(resp)
- .ok()?,
- flow::Transition::None,
- )),
+ Ok((resp, enable_condstore)) => {
+ if enable_condstore {
+ self.client_capabilities.enable_condstore();
+ }
+ Ok((
+ Response::build()
+ .to_req(self.req)
+ .message("FETCH completed")
+ .set_body(resp)
+ .ok()?,
+ flow::Transition::None,
+ ))
+ },
Err(e) => Ok((
Response::build()
.to_req(self.req)
diff --git a/src/imap/command/selected.rs b/src/imap/command/selected.rs
index ef2654e..24e1f41 100644
--- a/src/imap/command/selected.rs
+++ b/src/imap/command/selected.rs
@@ -117,14 +117,19 @@ impl<'a> SelectedContext<'a> {
uid: &bool,
) -> Result<(Response<'static>, flow::Transition)> {
match self.mailbox.fetch(sequence_set, attributes, uid).await {
- Ok(resp) => Ok((
- Response::build()
- .to_req(self.req)
- .message("FETCH completed")
- .set_body(resp)
- .ok()?,
- flow::Transition::None,
- )),
+ Ok((resp, enable_condstore)) => {
+ if enable_condstore {
+ self.client_capabilities.enable_condstore();
+ }
+ Ok((
+ Response::build()
+ .to_req(self.req)
+ .message("FETCH completed")
+ .set_body(resp)
+ .ok()?,
+ flow::Transition::None,
+ ))
+ },
Err(e) => Ok((
Response::build()
.to_req(self.req)
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index b3848b2..61beed5 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -259,7 +259,7 @@ impl MailboxView {
sequence_set: &SequenceSet,
attributes: &'b MacroOrMessageDataItemNames<'static>,
is_uid_fetch: &bool,
- ) -> Result<Vec<Body<'static>>> {
+ ) -> Result<(Vec<Body<'static>>, bool)> {
// [1/6] Pre-compute data
// a. what are the uuids of the emails we want?
// b. do we need to fetch the full body?
@@ -316,7 +316,7 @@ impl MailboxView {
.collect::<Result<_, _>>()?;
// [6/6] Build the final result that will be sent to the client.
- Ok(imap_ret)
+ Ok((imap_ret, ap.is_enabling_condstore()))
}
/// A naive search implementation...