aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mailbox_view.rs
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-06 18:51:21 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-06 18:51:21 +0100
commit870de493c84c6c3134d14ee8a234f124360354a7 (patch)
treeb9d763c6c845b78e09de4c8cc46ce0002f6d2d68 /src/imap/mailbox_view.rs
parentf58904f5bb3dbd429555c406c867f850654843a6 (diff)
downloadaerogramme-870de493c84c6c3134d14ee8a234f124360354a7.tar.gz
aerogramme-870de493c84c6c3134d14ee8a234f124360354a7.zip
Search is made more clear
Diffstat (limited to 'src/imap/mailbox_view.rs')
-rw-r--r--src/imap/mailbox_view.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index a07f6a4..3c43be8 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -319,24 +319,25 @@ impl MailboxView {
let selection = self.index().fetch(&seq_set, seq_type.is_uid())?;
// 3. Filter the selection based on the ID / UID / Flags
- let selection = crit.filter_on_idx(&selection);
+ let (kept_idx, to_fetch) = crit.filter_on_idx(&selection);
// 4. Fetch additional info about the emails
let query_scope = crit.query_scope();
- let uuids = selection
+ let uuids = to_fetch
.iter()
.map(|midx| midx.uuid)
.collect::<Vec<_>>();
let query_result = self.0.query(&uuids, query_scope).fetch().await?;
// 5. If needed, filter the selection based on the body
- let selection = crit.filter_on_query(&selection, &query_result);
+ let kept_query = crit.filter_on_query(&to_fetch, &query_result);
// 6. Format the result according to the client's taste:
// either return UID or ID.
+ let final_selection = kept_idx.into_iter().chain(kept_query.into_iter());
let selection_fmt = match uid {
- true => selection.into_iter().map(|in_idx| in_idx.uid).collect(),
- _ => selection.into_iter().map(|in_idx| in_idx.i).collect(),
+ true => final_selection.map(|in_idx| in_idx.uid).collect(),
+ _ => final_selection.map(|in_idx| in_idx.i).collect(),
};
Ok(vec![Body::Data(Data::Search(selection_fmt))])