aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/imap/mailbox_view.rs52
-rw-r--r--tests/emails/dxflrs/0003_mime-in-mime.body2
-rw-r--r--tests/emails/dxflrs/0003_mime-in-mime.bodystructure2
-rw-r--r--tests/emails/dxflrs/0003_mime-in-mime.eml7
-rw-r--r--tests/emails/dxflrs/0004_msg-in-msg.eml2
5 files changed, 48 insertions, 17 deletions
diff --git a/src/imap/mailbox_view.rs b/src/imap/mailbox_view.rs
index fdb87d0..f1d3df7 100644
--- a/src/imap/mailbox_view.rs
+++ b/src/imap/mailbox_view.rs
@@ -584,27 +584,48 @@ fn build_imap_email_struct<'a>(
extension_data: None,
})
}
- MessageStructure::MultiPart((id, l)) => {
- todo!()
- /*let part = msg.parts.get(id)?;
- let mp = match part {
- MessagePart::Multipart(mp) => mp,
- _ => unreachable!("Only a MessagePart part entry is allowed here.");
- }
+ MessageStructure::MultiPart((id, lp)) => {
+ let part = msg
+ .parts
+ .get(*id)
+ .map(|p| match p {
+ MessagePart::Multipart(mp) => Some(mp),
+ _ => None,
+ })
+ .flatten()
+ .ok_or(anyhow!(
+ "Email part referenced in email structure is missing"
+ ))?;
+ let subtype = IString::try_from(
+ part.headers_rfc
+ .get(&RfcHeader::ContentType)
+ .ok_or(anyhow!("Content-Type is missing but required here."))?
+ .get_content_type()
+ .c_subtype
+ .as_ref()
+ .ok_or(anyhow!("Content-Type invalid, missing subtype"))?
+ .to_string(),
+ )
+ .map_err(|_| {
+ anyhow!("Unable to build IString from given Content-Type subtype given")
+ })?;
- BodyStructure::Multi {
- bodies: l.map(|inner_node| build_email_struct(msg, inner_node)),
- subtype: "",
- extension_data: Some(MultipartExtensionData {
+ Ok(BodyStructure::Multi {
+ bodies: lp
+ .iter()
+ .map(|inner_node| build_imap_email_struct(msg, inner_node))
+ .fold(Ok(vec![]), try_collect_shime)?,
+ subtype,
+ extension_data: None,
+ /*Some(MultipartExtensionData {
parameter_list: vec![],
disposition: None,
language: None,
location: None,
extension: vec![],
- })
- }
- */
+ })*/
+ })
}
}
}
@@ -715,7 +736,7 @@ mod tests {
use imap_codec::codec::Encode;
use std::fs;
- /// Future automated test. We use lossy utf8 conversion + lowercasing everything,
+ /// Future automated test. We use lossy utf8 conversion + lowercase everything,
/// so this test might allow invalid results. But at least it allows us to quickly test a
/// large variety of emails.
/// Keep in mind that special cases must still be tested manually!
@@ -724,6 +745,7 @@ mod tests {
let prefixes = [
"tests/emails/dxflrs/0001_simple",
"tests/emails/dxflrs/0002_mime",
+ "tests/emails/dxflrs/0003_mime-in-mime",
];
for pref in prefixes.iter() {
diff --git a/tests/emails/dxflrs/0003_mime-in-mime.body b/tests/emails/dxflrs/0003_mime-in-mime.body
index 5c6c9f8..ddf0f6d 100644
--- a/tests/emails/dxflrs/0003_mime-in-mime.body
+++ b/tests/emails/dxflrs/0003_mime-in-mime.body
@@ -1 +1 @@
-(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0) "mixed") "mixed")) \ No newline at end of file
+(BODY ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed")("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1) "mixed")) \ No newline at end of file
diff --git a/tests/emails/dxflrs/0003_mime-in-mime.bodystructure b/tests/emails/dxflrs/0003_mime-in-mime.bodystructure
index e2535bb..903d343 100644
--- a/tests/emails/dxflrs/0003_mime-in-mime.bodystructure
+++ b/tests/emails/dxflrs/0003_mime-in-mime.bodystructure
@@ -1 +1 @@
-(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 7 0 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL)) \ No newline at end of file
+(BODYSTRUCTURE ((("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "child") NIL NIL NIL)("text" "plain" ("charset" "us-ascii") NIL NIL "7bit" 9 1 NIL NIL NIL NIL) "mixed" ("boundary" "parent") NIL NIL NIL)) \ No newline at end of file
diff --git a/tests/emails/dxflrs/0003_mime-in-mime.eml b/tests/emails/dxflrs/0003_mime-in-mime.eml
index f98c015..52f4e15 100644
--- a/tests/emails/dxflrs/0003_mime-in-mime.eml
+++ b/tests/emails/dxflrs/0003_mime-in-mime.eml
@@ -9,9 +9,16 @@ Content-Type: multipart/mixed; boundary="child";
Content-Type: text/plain; charset="us-ascii"
Hello 1
+
--child
Content-Type: text/plain; charset="us-ascii"
Hello 2
+
--child--
+--parent
+Content-Type: text/plain; charset="us-ascii"
+
+Hello 3
+
--parent--
diff --git a/tests/emails/dxflrs/0004_msg-in-msg.eml b/tests/emails/dxflrs/0004_msg-in-msg.eml
index 051d003..b1602cb 100644
--- a/tests/emails/dxflrs/0004_msg-in-msg.eml
+++ b/tests/emails/dxflrs/0004_msg-in-msg.eml
@@ -9,3 +9,5 @@ From: Garage team <garagehq@deuxfleurs.fr>
Subject: Welcome to Aerogramme!!
This is just a test email, feel free to ignore.
+
+--delim--