aboutsummaryrefslogtreecommitdiff
path: root/src/imap/mailbox_view.rs
diff options
context:
space:
mode:
authorQuentin <quentin@dufour.io>2024-01-08 20:34:58 +0000
committerQuentin <quentin@dufour.io>2024-01-08 20:34:58 +0000
commit356776cba35c450f6f7be9382c44df6d7b752ef1 (patch)
tree407ba90198f508fdf83c8619a68cd546a2b068f2 /src/imap/mailbox_view.rs
parentb8b9e20ac05e60b3bd156ff8f995ae74ae9222f2 (diff)
parent5cc0a4e5129020aad1d5a7ab1cc976fb6bdc259a (diff)
downloadaerogramme-356776cba35c450f6f7be9382c44df6d7b752ef1.tar.gz
aerogramme-356776cba35c450f6f7be9382c44df6d7b752ef1.zip
Merge pull request 'bug/thunderbird' (#68) from bug/thunderbird into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/aerogramme/pulls/68
Diffstat (limited to 'src/imap/mailbox_view.rs')
-rw-r--r--src/imap/mailbox_view.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index 77fe7f7..513567f 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -130,6 +130,8 @@ impl MailboxView {
data.extend(self.flags_status()?.into_iter());
data.push(self.uidvalidity_status()?);
data.push(self.uidnext_status()?);
+ self.unseen_first_status()?
+ .map(|unseen_status| data.push(unseen_status));
Ok(data)
}
@@ -257,6 +259,7 @@ impl MailboxView {
true => QueryScope::Full,
_ => QueryScope::Partial,
};
+ tracing::debug!("Query scope {:?}", query_scope);
let idx = self.index()?;
let mail_idx_list = idx.fetch(sequence_set, *is_uid_fetch)?;
@@ -400,6 +403,27 @@ impl MailboxView {
Ok(Body::Data(Data::Recent(self.recent()?)))
}
+ fn unseen_first_status(&self) -> Result<Option<Body<'static>>> {
+ Ok(self
+ .unseen_first()?
+ .map(|unseen_id| {
+ Status::ok(None, Some(Code::Unseen(unseen_id)), "First unseen.").map(Body::Status)
+ })
+ .transpose()?)
+ }
+
+ fn unseen_first(&self) -> Result<Option<NonZeroU32>> {
+ Ok(self
+ .0
+ .snapshot
+ .table
+ .values()
+ .enumerate()
+ .find(|(_i, (_imap_uid, flags))| !flags.contains(&"\\Seen".to_string()))
+ .map(|(i, _)| NonZeroU32::try_from(i as u32 + 1))
+ .transpose()?)
+ }
+
pub(crate) fn recent(&self) -> Result<u32> {
let recent = self
.0
@@ -521,7 +545,6 @@ mod tests {
let rfc822 = b"Subject: hello\r\nFrom: a@a.a\r\nTo: b@b.b\r\nDate: Thu, 12 Oct 2023 08:45:28 +0000\r\n\r\nhello world";
let qr = QueryResult::FullResult {
uuid: mail_in_idx.uuid.clone(),
- index: &index_entry,
metadata: meta,
content: rfc822.to_vec(),
};
@@ -596,6 +619,7 @@ mod tests {
seq: NonZeroU32::new(1).unwrap(),
items: NonEmptyVec::from(MessageDataItem::Body(mime_view::bodystructure(
&message.child,
+ false,
)?)),
});
let test_bytes = ResponseCodec::new().encode(&test_repr).dump();