diff --git a/CHANGELOG.md b/CHANGELOG.md index 3c1810e..831d700 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Output redirected to `stderr` [#130] - Refactor table system [#132] - Editon file format on Linux [#133] +- Show email address when name not available [#131] ## [0.2.6] - 2021-04-17 @@ -211,5 +212,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#125]: https://github.com/soywod/himalaya/issues/125 [#126]: https://github.com/soywod/himalaya/issues/126 [#130]: https://github.com/soywod/himalaya/issues/130 +[#131]: https://github.com/soywod/himalaya/issues/131 [#132]: https://github.com/soywod/himalaya/issues/132 [#133]: https://github.com/soywod/himalaya/issues/133 diff --git a/src/msg/model.rs b/src/msg/model.rs index 53b9ebb..dd01a9c 100644 --- a/src/msg/model.rs +++ b/src/msg/model.rs @@ -262,9 +262,23 @@ impl<'m> From<&'m imap::types::Fetch> for Msg<'m> { sender: envelope .from .as_ref() - .and_then(|addrs| addrs.first()?.name) - .and_then(|name| rfc2047_decoder::decode(name).ok()) - .unwrap_or_default(), + .and_then(|addrs| addrs.first()) + .and_then(|addr| { + addr.name + .and_then(|name| rfc2047_decoder::decode(name).ok()) + .or_else(|| { + let mbox = addr + .mailbox + .and_then(|mbox| String::from_utf8(mbox.to_vec()).ok()) + .unwrap_or(String::from("unknown")); + let host = addr + .host + .and_then(|host| String::from_utf8(host.to_vec()).ok()) + .unwrap_or(String::from("unknown")); + Some(format!("{}@{}", mbox, host)) + }) + }) + .unwrap_or(String::from("unknown")), date: fetch .internal_date() .map(|date| date.naive_local().to_string())