diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-30 13:36:21 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2022-06-30 13:36:39 +0200 |
commit | 0f0a8d415e45df178778260d3be1b83ab2785675 (patch) | |
tree | d92d0dea55a7dafcbf85377163dfcbb889008a10 /src/imap/mailbox_view.rs | |
parent | 69428eaf257db396ae72007aa78d40406c29407c (diff) | |
download | aerogramme-0f0a8d415e45df178778260d3be1b83ab2785675.tar.gz aerogramme-0f0a8d415e45df178778260d3be1b83ab2785675.zip |
Implement RFC822.TEXT
Diffstat (limited to 'src/imap/mailbox_view.rs')
-rw-r--r-- | src/imap/mailbox_view.rs | 46 |
1 files changed, 37 insertions, 9 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs index 58e71a2..0feb588 100644 --- a/src/imap/mailbox_view.rs +++ b/src/imap/mailbox_view.rs @@ -6,7 +6,7 @@ use anyhow::{anyhow, bail, Error, Result}; use boitalettres::proto::res::body::Data as Body; use futures::stream::{FuturesOrdered, StreamExt}; use imap_codec::types::address::Address; -use imap_codec::types::core::{Atom, IString, NString}; +use imap_codec::types::core::{Atom, IString, NString, NonZeroBytes}; use imap_codec::types::envelope::Envelope; use imap_codec::types::fetch_attributes::{FetchAttribute, MacroOrFetchAttributes}; use imap_codec::types::flag::Flag; @@ -247,21 +247,49 @@ impl MailboxView { FetchAttribute::Rfc822Size => { attributes.push(MessageAttribute::Rfc822Size(meta.rfc822_size as u32)) } - FetchAttribute::Rfc822Header => { - attributes.push(MessageAttribute::Rfc822Header(NString(Some( - IString::Literal(meta.headers.clone().try_into().unwrap()), + FetchAttribute::Rfc822Header => attributes.push( + MessageAttribute::Rfc822Header(NString(Some(IString::Literal( + meta.headers + .clone() + .try_into() + .or(Err(Error::msg("IString conversion error")))?, + )))), + ), + FetchAttribute::Rfc822Text => { + let r = parsed + .raw_message.get(parsed.offset_body..parsed.offset_end) + .ok_or(Error::msg("Unable to extract email body, cursors out of bound. This is a bug."))? + .try_into() + .or(Err(Error::msg("IString conversion error")))?; + + attributes.push(MessageAttribute::Rfc822Text(NString(Some( + IString::Literal(r), )))) } FetchAttribute::Rfc822 => { - attributes.push(MessageAttribute::Rfc822(NString(Some( - IString::Literal(body.as_ref().unwrap().clone().try_into().unwrap()), - )))) + attributes.push(MessageAttribute::Rfc822(NString(Some(IString::Literal( + body.as_ref().unwrap().clone().try_into().unwrap(), + ))))) } FetchAttribute::Envelope => { attributes.push(MessageAttribute::Envelope(message_envelope(&parsed))) } - // TODO - _ => (), + FetchAttribute::Body => { + todo!() + } + FetchAttribute::BodyExt { + section, + partial, + peek, + } => { + todo!() + } + FetchAttribute::BodyStructure => { + todo!() + } + FetchAttribute::InternalDate => { + todo!() + } } } |