diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-08 15:07:02 +0100 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-01-08 15:07:02 +0100 |
commit | 8b5eb25c0cce525f92e29062b76853ee4ad27f62 (patch) | |
tree | 69cece570178c5b8206e3466f14349aa6cd153b0 /src/imap/mail_view.rs | |
parent | 0acbbe66c1f05f380caa8abe293ef273d347ba81 (diff) | |
download | aerogramme-8b5eb25c0cce525f92e29062b76853ee4ad27f62.tar.gz aerogramme-8b5eb25c0cce525f92e29062b76853ee4ad27f62.zip |
Status now returns UNSEEN
Diffstat (limited to 'src/imap/mail_view.rs')
-rw-r--r-- | src/imap/mail_view.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/imap/mail_view.rs b/src/imap/mail_view.rs index 7da21c4..4b18021 100644 --- a/src/imap/mail_view.rs +++ b/src/imap/mail_view.rs @@ -74,7 +74,12 @@ impl<'a> MailView<'a> { MessageDataItemName::Rfc822Size => self.rfc_822_size(), MessageDataItemName::Rfc822Header => self.rfc_822_header(), MessageDataItemName::Rfc822Text => self.rfc_822_text(), - MessageDataItemName::Rfc822 => self.rfc822(), + MessageDataItemName::Rfc822 => { + if self.is_not_yet_seen() { + seen = SeenFlag::MustAdd; + } + self.rfc822() + }, MessageDataItemName::Envelope => Ok(self.envelope()), MessageDataItemName::Body => self.body(), MessageDataItemName::BodyStructure => self.body_structure(), @@ -189,6 +194,11 @@ impl<'a> MailView<'a> { )?)) } + fn is_not_yet_seen(&self) -> bool { + let seen_flag = Flag::Seen.to_string(); + !self.in_idx.flags.iter().any(|x| *x == seen_flag) + } + /// maps to BODY[<section>]<<partial>> and BODY.PEEK[<section>]<<partial>> /// peek does not implicitly set the \Seen flag /// eg. BODY[HEADER.FIELDS (DATE FROM)] @@ -201,8 +211,7 @@ impl<'a> MailView<'a> { ) -> Result<(MessageDataItem<'static>, SeenFlag)> { // Manage Seen flag let mut seen = SeenFlag::DoNothing; - let seen_flag = Flag::Seen.to_string(); - if !peek && !self.in_idx.flags.iter().any(|x| *x == seen_flag) { + if !peek && self.is_not_yet_seen() { // Add \Seen flag //self.mailbox.add_flags(uuid, &[seen_flag]).await?; seen = SeenFlag::MustAdd; |