From ba17174e9482503c089ff9d6deab96c0f1168022 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Thu, 2 Jan 2020 17:35:32 +0100 Subject: Optimization: Get the Message-Id from the header, if it is there Signed-off-by: Matthias Beyer --- lib/domain/libimagmail/src/mail.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/domain/libimagmail/src/mail.rs b/lib/domain/libimagmail/src/mail.rs index 78d2e67a..1d2f5a2d 100644 --- a/lib/domain/libimagmail/src/mail.rs +++ b/lib/domain/libimagmail/src/mail.rs @@ -20,6 +20,7 @@ use failure::Fallible as Result; use failure::ResultExt; use failure::Error; +use toml_query::read::TomlValueReadExt; use libimagstore::store::Entry; use libimagentryutil::isa::Is; @@ -113,8 +114,14 @@ impl Mail for Entry { /// /// Use `Mail::mail_header()` if you need to read more than one field. fn get_message_id(&self, refconfig: &RefConfig) -> Result> { - self.get_field(refconfig, "Message-ID") - .map(|o| o.map(crate::util::strip_message_delimiters).map(MessageId::from)) + if let Some(s) = self.get_header().read("mail.message-id")? { + let s = s.as_str() + .ok_or_else(|| format_err!("'mail.message-id' is not a String in {}", self.get_location()))?; + Ok(Some(MessageId::from(String::from(s)))) + } else { + self.get_field(refconfig, "Message-ID") + .map(|o| o.map(crate::util::strip_message_delimiters).map(MessageId::from)) + } } /// Get a value of the `In-Reply-To` field of the mail file -- cgit v1.2.3