From f5b73182f25dfdcdc34f7b3c6664c5112ce93c1c Mon Sep 17 00:00:00 2001 From: Quentin Dufour Date: Wed, 10 Jan 2024 18:08:44 +0100 Subject: Fetch now support MODSEQ data item --- Cargo.lock | 4 ++-- src/imap/index.rs | 10 +++++----- src/imap/mail_view.rs | 5 +++++ 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e2992b7..2f9e5b4 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#eb37f06a0e8d2543f60063ec80cde9e9dcb150f1" +source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#990e709450ff4f8986b08d2b84e28f651b74f181" 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#eb37f06a0e8d2543f60063ec80cde9e9dcb150f1" +source = "git+https://github.com/superboum/imap-codec?branch=custom/aerogramme#990e709450ff4f8986b08d2b84e28f651b74f181" dependencies = [ "base64 0.21.5", "bounded-static", diff --git a/src/imap/index.rs b/src/imap/index.rs index da94022..44109d5 100644 --- a/src/imap/index.rs +++ b/src/imap/index.rs @@ -3,7 +3,7 @@ use std::num::NonZeroU32; use anyhow::{anyhow, Result}; use imap_codec::imap_types::sequence::{SeqOrUid, Sequence, SequenceSet}; -use crate::mail::uidindex::{ImapUid, UidIndex}; +use crate::mail::uidindex::{ImapUid, ModSeq, UidIndex}; use crate::mail::unique_ident::UniqueIdent; pub struct Index<'a> { @@ -17,12 +17,10 @@ impl<'a> Index<'a> { .iter() .enumerate() .map(|(i_enum, (&uid, &uuid))| { - let flags = internal + let (_, modseq, flags) = internal .table .get(&uuid) - .ok_or(anyhow!("mail is missing from index"))? - .2 - .as_ref(); + .ok_or(anyhow!("mail is missing from index"))?; let i_int: u32 = (i_enum + 1).try_into()?; let i: NonZeroU32 = i_int.try_into()?; @@ -30,6 +28,7 @@ impl<'a> Index<'a> { i, uid, uuid, + modseq: *modseq, flags, }) }) @@ -134,6 +133,7 @@ pub struct MailIndex<'a> { pub i: NonZeroU32, pub uid: ImapUid, pub uuid: UniqueIdent, + pub modseq: ModSeq, pub flags: &'a Vec, } diff --git a/src/imap/mail_view.rs b/src/imap/mail_view.rs index eeb6b4b..a8db733 100644 --- a/src/imap/mail_view.rs +++ b/src/imap/mail_view.rs @@ -90,6 +90,7 @@ impl<'a> MailView<'a> { Ok(body) } MessageDataItemName::InternalDate => self.internal_date(), + MessageDataItemName::ModSeq => Ok(self.modseq()), }) .collect::, _>>()?; @@ -252,6 +253,10 @@ impl<'a> MailView<'a> { .ok_or(anyhow!("Unable to parse internal date"))?; Ok(MessageDataItem::InternalDate(DateTime::unvalidated(dt))) } + + fn modseq(&self) -> MessageDataItem<'static> { + MessageDataItem::ModSeq(self.in_idx.modseq) + } } pub enum SeenFlag { -- cgit v1.2.3