From 435932a50186f563227e25782cc275828addb634 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20DOUIN?= Date: Tue, 4 May 2021 16:19:06 +0200 Subject: [PATCH] get signature from file (#135) --- CHANGELOG.md | 5 +++++ src/config/model.rs | 17 +++++++++++++---- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1650075..977b28f 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] +### Changed + +- Get signature from file [#135] + ## [0.3.1] - 2021-05-04 ### Added @@ -239,6 +243,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#131]: https://github.com/soywod/himalaya/issues/131 [#132]: https://github.com/soywod/himalaya/issues/132 [#133]: https://github.com/soywod/himalaya/issues/133 +[#135]: https://github.com/soywod/himalaya/issues/135 [#136]: https://github.com/soywod/himalaya/issues/136 [#138]: https://github.com/soywod/himalaya/issues/138 [#141]: https://github.com/soywod/himalaya/issues/141 diff --git a/src/config/model.rs b/src/config/model.rs index f0fe522..c36be06 100644 --- a/src/config/model.rs +++ b/src/config/model.rs @@ -2,7 +2,14 @@ use error_chain::error_chain; use lettre::transport::smtp::authentication::Credentials as SmtpCredentials; use log::debug; use serde::Deserialize; -use std::{collections::HashMap, env, fs::File, io::Read, path::PathBuf, thread}; +use std::{ + collections::HashMap, + env, + fs::{self, File}, + io::Read, + path::PathBuf, + thread, +}; use toml; use crate::output::utils::run_cmd; @@ -220,11 +227,13 @@ impl Config { } pub fn signature(&self, account: &Account) -> Option { - account + let sig = account .signature .as_ref() - .or_else(|| self.signature.as_ref()) - .map(|sig| sig.to_owned()) + .or_else(|| self.signature.as_ref()); + + sig.and_then(|sig| fs::read_to_string(sig).ok()) + .or_else(|| sig.map(|sig| sig.to_owned())) } pub fn default_page_size(&self, account: &Account) -> usize {