mirror of
https://github.com/soywod/himalaya.git
synced 2024-11-25 12:30:22 +00:00
introduce signature feature
This commit is contained in:
parent
1a26ac4b2c
commit
17115319ee
2 changed files with 49 additions and 0 deletions
|
@ -16,6 +16,7 @@ pub struct Account {
|
|||
// Override
|
||||
pub name: Option<String>,
|
||||
pub downloads_dir: Option<PathBuf>,
|
||||
pub signature: Option<String>,
|
||||
|
||||
// Specific
|
||||
pub default: Option<bool>,
|
||||
|
@ -76,6 +77,7 @@ pub struct Config {
|
|||
pub name: String,
|
||||
pub downloads_dir: Option<PathBuf>,
|
||||
pub notify_cmd: Option<String>,
|
||||
pub signature: Option<String>,
|
||||
|
||||
#[serde(flatten)]
|
||||
pub accounts: HashMap<String, Account>,
|
||||
|
@ -170,4 +172,12 @@ impl Config {
|
|||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn signature(&self, account: &Account) -> Option<String> {
|
||||
account
|
||||
.signature
|
||||
.as_ref()
|
||||
.or_else(|| self.signature.as_ref())
|
||||
.map(|sig| sig.to_owned())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -360,6 +360,18 @@ impl<'m> Msg<'m> {
|
|||
// "Subject" header
|
||||
tpl.push("Subject: ".to_string());
|
||||
|
||||
// Separator between headers and body
|
||||
tpl.push(String::new());
|
||||
|
||||
// Signature
|
||||
if let Some(sig) = config.signature(&account) {
|
||||
tpl.push(String::new());
|
||||
tpl.push("--".to_string());
|
||||
for line in sig.split("\n") {
|
||||
tpl.push(line.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Tpl(tpl.join("\r\n")))
|
||||
}
|
||||
|
||||
|
@ -404,6 +416,15 @@ impl<'m> Msg<'m> {
|
|||
.join("\r\n");
|
||||
tpl.push(thread);
|
||||
|
||||
// Signature
|
||||
if let Some(sig) = config.signature(&account) {
|
||||
tpl.push(String::new());
|
||||
tpl.push("--".to_string());
|
||||
for line in sig.split("\n") {
|
||||
tpl.push(line.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Tpl(tpl.join("\r\n")))
|
||||
}
|
||||
|
||||
|
@ -489,6 +510,15 @@ impl<'m> Msg<'m> {
|
|||
.join("\r\n");
|
||||
tpl.push(thread);
|
||||
|
||||
// Signature
|
||||
if let Some(sig) = config.signature(&account) {
|
||||
tpl.push(String::new());
|
||||
tpl.push("--".to_string());
|
||||
for line in sig.split("\n") {
|
||||
tpl.push(line.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Tpl(tpl.join("\r\n")))
|
||||
}
|
||||
|
||||
|
@ -518,6 +548,15 @@ impl<'m> Msg<'m> {
|
|||
tpl.push("-------- Forwarded Message --------".to_string());
|
||||
tpl.push(self.text_bodies("text/plain")?);
|
||||
|
||||
// Signature
|
||||
if let Some(sig) = config.signature(&account) {
|
||||
tpl.push(String::new());
|
||||
tpl.push("--".to_string());
|
||||
for line in sig.split("\n") {
|
||||
tpl.push(line.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(Tpl(tpl.join("\r\n")))
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue