diff --git a/CHANGELOG.md b/CHANGELOG.md index 33ae576..f732a8d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Fixed + +- Error on empty subject [#229] + ## [0.5.0] - 2021-10-10 ### Added @@ -333,3 +337,4 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#199]: https://github.com/soywod/himalaya/issues/199 [#205]: https://github.com/soywod/himalaya/issues/205 [#215]: https://github.com/soywod/himalaya/issues/215 +[#229]: https://github.com/soywod/himalaya/issues/229 diff --git a/src/domain/msg/envelope_entity.rs b/src/domain/msg/envelope_entity.rs index 2b49eea..a5af8f3 100644 --- a/src/domain/msg/envelope_entity.rs +++ b/src/domain/msg/envelope_entity.rs @@ -51,13 +51,13 @@ impl<'a> TryFrom<&'a RawEnvelope> for Envelope<'a> { let subject: Cow = envelope .subject .as_ref() - .ok_or(anyhow!("cannot get subject of message {}", fetch.message)) - .and_then(|subj| { + .map(|subj| { rfc2047_decoder::decode(subj).context(format!( "cannot decode subject of message {}", fetch.message )) - })? + }) + .unwrap_or(Ok(String::default()))? .into(); // Get the sender diff --git a/src/domain/msg/msg_entity.rs b/src/domain/msg/msg_entity.rs index 0afc54e..a1dca68 100644 --- a/src/domain/msg/msg_entity.rs +++ b/src/domain/msg/msg_entity.rs @@ -705,13 +705,13 @@ impl<'a> TryFrom<&'a imap::types::Fetch> for Msg { let subject = envelope .subject .as_ref() - .ok_or(anyhow!("cannot get subject of message {}", fetch.message)) - .and_then(|subj| { + .map(|subj| { rfc2047_decoder::decode(subj).context(format!( "cannot decode subject of message {}", fetch.message )) - })?; + }) + .unwrap_or(Ok(String::default()))?; // Get the sender(s) address(es) let from = match envelope