CONDSTORE #71
4 changed files with 34 additions and 18 deletions
|
@ -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 {
|
||||
|
|
|
@ -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((
|
||||
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)
|
||||
|
|
|
@ -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((
|
||||
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)
|
||||
|
|
|
@ -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...
|
||||
|
|
Loading…
Reference in a new issue