diff options
author | Quentin <quentin@dufour.io> | 2024-01-08 20:34:58 +0000 |
---|---|---|
committer | Quentin <quentin@dufour.io> | 2024-01-08 20:34:58 +0000 |
commit | 356776cba35c450f6f7be9382c44df6d7b752ef1 (patch) | |
tree | 407ba90198f508fdf83c8619a68cd546a2b068f2 /src/imap/mail_view.rs | |
parent | b8b9e20ac05e60b3bd156ff8f995ae74ae9222f2 (diff) | |
parent | 5cc0a4e5129020aad1d5a7ab1cc976fb6bdc259a (diff) | |
download | aerogramme-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/mail_view.rs')
-rw-r--r-- | src/imap/mail_view.rs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/imap/mail_view.rs b/src/imap/mail_view.rs index 7da21c4..eeb6b4b 100644 --- a/src/imap/mail_view.rs +++ b/src/imap/mail_view.rs @@ -27,15 +27,12 @@ use crate::imap::response::Body; pub struct MailView<'a> { pub in_idx: &'a MailIndex<'a>, - pub query_result: &'a QueryResult<'a>, + pub query_result: &'a QueryResult, pub content: FetchedMail<'a>, } impl<'a> MailView<'a> { - pub fn new( - query_result: &'a QueryResult<'a>, - in_idx: &'a MailIndex<'a>, - ) -> Result<MailView<'a>> { + pub fn new(query_result: &'a QueryResult, in_idx: &'a MailIndex<'a>) -> Result<MailView<'a>> { Ok(Self { in_idx, query_result, @@ -74,7 +71,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(), @@ -180,15 +182,22 @@ impl<'a> MailView<'a> { fn body(&self) -> Result<MessageDataItem<'static>> { Ok(MessageDataItem::Body(mime_view::bodystructure( self.content.as_msg()?.child.as_ref(), + false, )?)) } fn body_structure(&self) -> Result<MessageDataItem<'static>> { - Ok(MessageDataItem::Body(mime_view::bodystructure( + Ok(MessageDataItem::BodyStructure(mime_view::bodystructure( self.content.as_msg()?.child.as_ref(), + true, )?)) } + 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 +210,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; |