Fecth MODSEQ now enables the CONDSTORE capability

This commit is contained in:
Quentin 2024-01-10 18:38:21 +01:00
parent f5b73182f2
commit f4cbf66549
Signed by: quentin
GPG key ID: E9602264D639FF68
4 changed files with 34 additions and 18 deletions

View file

@ -34,6 +34,12 @@ impl AttributesProxy {
Self { attrs: fetch_attrs } 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 { pub fn need_body(&self) -> bool {
self.attrs.iter().any(|x| { self.attrs.iter().any(|x| {
match x { match x {

View file

@ -91,14 +91,19 @@ impl<'a> ExaminedContext<'a> {
uid: &bool, uid: &bool,
) -> Result<(Response<'static>, flow::Transition)> { ) -> Result<(Response<'static>, flow::Transition)> {
match self.mailbox.fetch(sequence_set, attributes, uid).await { match self.mailbox.fetch(sequence_set, attributes, uid).await {
Ok(resp) => Ok(( Ok((resp, enable_condstore)) => {
Response::build() if enable_condstore {
.to_req(self.req) self.client_capabilities.enable_condstore();
.message("FETCH completed") }
.set_body(resp) Ok((
.ok()?, Response::build()
flow::Transition::None, .to_req(self.req)
)), .message("FETCH completed")
.set_body(resp)
.ok()?,
flow::Transition::None,
))
},
Err(e) => Ok(( Err(e) => Ok((
Response::build() Response::build()
.to_req(self.req) .to_req(self.req)

View file

@ -117,14 +117,19 @@ impl<'a> SelectedContext<'a> {
uid: &bool, uid: &bool,
) -> Result<(Response<'static>, flow::Transition)> { ) -> Result<(Response<'static>, flow::Transition)> {
match self.mailbox.fetch(sequence_set, attributes, uid).await { match self.mailbox.fetch(sequence_set, attributes, uid).await {
Ok(resp) => Ok(( Ok((resp, enable_condstore)) => {
Response::build() if enable_condstore {
.to_req(self.req) self.client_capabilities.enable_condstore();
.message("FETCH completed") }
.set_body(resp) Ok((
.ok()?, Response::build()
flow::Transition::None, .to_req(self.req)
)), .message("FETCH completed")
.set_body(resp)
.ok()?,
flow::Transition::None,
))
},
Err(e) => Ok(( Err(e) => Ok((
Response::build() Response::build()
.to_req(self.req) .to_req(self.req)

View file

@ -259,7 +259,7 @@ impl MailboxView {
sequence_set: &SequenceSet, sequence_set: &SequenceSet,
attributes: &'b MacroOrMessageDataItemNames<'static>, attributes: &'b MacroOrMessageDataItemNames<'static>,
is_uid_fetch: &bool, is_uid_fetch: &bool,
) -> Result<Vec<Body<'static>>> { ) -> Result<(Vec<Body<'static>>, bool)> {
// [1/6] Pre-compute data // [1/6] Pre-compute data
// a. what are the uuids of the emails we want? // a. what are the uuids of the emails we want?
// b. do we need to fetch the full body? // b. do we need to fetch the full body?
@ -316,7 +316,7 @@ impl MailboxView {
.collect::<Result<_, _>>()?; .collect::<Result<_, _>>()?;
// [6/6] Build the final result that will be sent to the client. // [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... /// A naive search implementation...