aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorQuentin Dufour <quentin@deuxfleurs.fr>2024-01-11 11:55:40 +0100
committerQuentin Dufour <quentin@deuxfleurs.fr>2024-01-11 11:55:40 +0100
commita9d33c67080fd08b057501c36a07fade351bd83d (patch)
treea499d27f24db85811a39ec513ef7708eed2151f1
parentfbf2e9aa9670c991f5384350b2c78ad38dc3baf8 (diff)
downloadaerogramme-a9d33c67080fd08b057501c36a07fade351bd83d.tar.gz
aerogramme-a9d33c67080fd08b057501c36a07fade351bd83d.zip
MODSEQ is now returned on non empty search results
-rw-r--r--Cargo.lock4
-rw-r--r--src/imap/mailbox_view.rs13
2 files changed, 12 insertions, 5 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 54972a4..dae5cb9 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -1807,7 +1807,7 @@ dependencies = [
[[package]]
name = "imap-codec"
version = "2.0.0"
-source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#088fa93bfb4040fc4364aa6e9487fff4375429c3"
+source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#3fdc1f3184ec121823d44b3f39e56b448ac80751"
dependencies = [
"abnf-core",
"base64 0.21.5",
@@ -1834,7 +1834,7 @@ dependencies = [
[[package]]
name = "imap-types"
version = "2.0.0"
-source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#088fa93bfb4040fc4364aa6e9487fff4375429c3"
+source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#3fdc1f3184ec121823d44b3f39e56b448ac80751"
dependencies = [
"base64 0.21.5",
"bounded-static",
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index ecdd745..9e9e785 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -1,4 +1,4 @@
-use std::num::NonZeroU32;
+use std::num::{NonZeroU32, NonZeroU64};
use std::sync::Arc;
use anyhow::{anyhow, Error, Result};
@@ -348,7 +348,7 @@ impl MailboxView {
// 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 final_selection = kept_idx.iter().chain(kept_query.iter());
let selection_fmt = match uid {
true => final_selection.map(|in_idx| in_idx.uid).collect(),
_ => final_selection.map(|in_idx| in_idx.i).collect(),
@@ -356,8 +356,15 @@ impl MailboxView {
// 7. Add the modseq entry if needed
let is_modseq = crit.is_modseq();
+ let maybe_modseq = match is_modseq {
+ true => {
+ let final_selection = kept_idx.iter().chain(kept_query.iter());
+ final_selection.map(|in_idx| in_idx.modseq).max().map(|r| NonZeroU64::try_from(r)).transpose()?
+ },
+ _ => None,
+ };
- Ok((vec![Body::Data(Data::Search(selection_fmt))], is_modseq))
+ Ok((vec![Body::Data(Data::Search(selection_fmt, maybe_modseq))], is_modseq))
}
// ----