get signature from file (#135)

This commit is contained in:
Clément DOUIN 2021-05-04 16:19:06 +02:00
parent 9ba0c75c58
commit 435932a501
No known key found for this signature in database
GPG key ID: 69C9B9CFFDEE2DEF
2 changed files with 18 additions and 4 deletions

View file

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased] ## [Unreleased]
### Changed
- Get signature from file [#135]
## [0.3.1] - 2021-05-04 ## [0.3.1] - 2021-05-04
### Added ### 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 [#131]: https://github.com/soywod/himalaya/issues/131
[#132]: https://github.com/soywod/himalaya/issues/132 [#132]: https://github.com/soywod/himalaya/issues/132
[#133]: https://github.com/soywod/himalaya/issues/133 [#133]: https://github.com/soywod/himalaya/issues/133
[#135]: https://github.com/soywod/himalaya/issues/135
[#136]: https://github.com/soywod/himalaya/issues/136 [#136]: https://github.com/soywod/himalaya/issues/136
[#138]: https://github.com/soywod/himalaya/issues/138 [#138]: https://github.com/soywod/himalaya/issues/138
[#141]: https://github.com/soywod/himalaya/issues/141 [#141]: https://github.com/soywod/himalaya/issues/141

View file

@ -2,7 +2,14 @@ use error_chain::error_chain;
use lettre::transport::smtp::authentication::Credentials as SmtpCredentials; use lettre::transport::smtp::authentication::Credentials as SmtpCredentials;
use log::debug; use log::debug;
use serde::Deserialize; 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 toml;
use crate::output::utils::run_cmd; use crate::output::utils::run_cmd;
@ -220,11 +227,13 @@ impl Config {
} }
pub fn signature(&self, account: &Account) -> Option<String> { pub fn signature(&self, account: &Account) -> Option<String> {
account let sig = account
.signature .signature
.as_ref() .as_ref()
.or_else(|| self.signature.as_ref()) .or_else(|| self.signature.as_ref());
.map(|sig| sig.to_owned())
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 { pub fn default_page_size(&self, account: &Account) -> usize {