Enable CONDSTORE if SEARCH MODSEQ is queried
This commit is contained in:
parent
917c32ae0b
commit
fbf2e9aa96
4 changed files with 24 additions and 4 deletions
|
@ -120,7 +120,10 @@ impl<'a> ExaminedContext<'a> {
|
|||
criteria: &SearchKey<'a>,
|
||||
uid: &bool,
|
||||
) -> Result<(Response<'static>, flow::Transition)> {
|
||||
let found = self.mailbox.search(charset, criteria, *uid).await?;
|
||||
let (found, enable_condstore) = self.mailbox.search(charset, criteria, *uid).await?;
|
||||
if enable_condstore {
|
||||
self.client_capabilities.enable_condstore();
|
||||
}
|
||||
Ok((
|
||||
Response::build()
|
||||
.to_req(self.req)
|
||||
|
|
|
@ -146,7 +146,10 @@ impl<'a> SelectedContext<'a> {
|
|||
criteria: &SearchKey<'a>,
|
||||
uid: &bool,
|
||||
) -> Result<(Response<'static>, flow::Transition)> {
|
||||
let found = self.mailbox.search(charset, criteria, *uid).await?;
|
||||
let (found, enable_condstore) = self.mailbox.search(charset, criteria, *uid).await?;
|
||||
if enable_condstore {
|
||||
self.client_capabilities.enable_condstore();
|
||||
}
|
||||
Ok((
|
||||
Response::build()
|
||||
.to_req(self.req)
|
||||
|
|
|
@ -325,7 +325,7 @@ impl MailboxView {
|
|||
_charset: &Option<Charset<'a>>,
|
||||
search_key: &SearchKey<'a>,
|
||||
uid: bool,
|
||||
) -> Result<Vec<Body<'static>>> {
|
||||
) -> Result<(Vec<Body<'static>>, bool)> {
|
||||
// 1. Compute the subset of sequence identifiers we need to fetch
|
||||
// based on the search query
|
||||
let crit = search::Criteria(search_key);
|
||||
|
@ -354,7 +354,10 @@ impl MailboxView {
|
|||
_ => final_selection.map(|in_idx| in_idx.i).collect(),
|
||||
};
|
||||
|
||||
Ok(vec![Body::Data(Data::Search(selection_fmt))])
|
||||
// 7. Add the modseq entry if needed
|
||||
let is_modseq = crit.is_modseq();
|
||||
|
||||
Ok((vec![Body::Data(Data::Search(selection_fmt))], is_modseq))
|
||||
}
|
||||
|
||||
// ----
|
||||
|
|
|
@ -112,6 +112,17 @@ impl<'a> Criteria<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn is_modseq(&self) -> bool {
|
||||
use SearchKey::*;
|
||||
match self.0 {
|
||||
And(and_list) => and_list.as_ref().iter().any(|child| Criteria(child).is_modseq()),
|
||||
Or(left, right) => Criteria(left).is_modseq() || Criteria(right).is_modseq(),
|
||||
Not(child) => Criteria(child).is_modseq(),
|
||||
ModSeq { .. } => true,
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns emails that we now for sure we want to keep
|
||||
/// but also a second list of emails we need to investigate further by
|
||||
/// fetching some remote data
|
||||
|
|
Loading…
Reference in a new issue