mirror of
https://github.com/soywod/himalaya.git
synced 2024-07-08 18:45:13 +00:00
introduce signature feature
This commit is contained in:
parent
1a26ac4b2c
commit
17115319ee
|
@ -16,6 +16,7 @@ pub struct Account {
|
||||||
// Override
|
// Override
|
||||||
pub name: Option<String>,
|
pub name: Option<String>,
|
||||||
pub downloads_dir: Option<PathBuf>,
|
pub downloads_dir: Option<PathBuf>,
|
||||||
|
pub signature: Option<String>,
|
||||||
|
|
||||||
// Specific
|
// Specific
|
||||||
pub default: Option<bool>,
|
pub default: Option<bool>,
|
||||||
|
@ -76,6 +77,7 @@ pub struct Config {
|
||||||
pub name: String,
|
pub name: String,
|
||||||
pub downloads_dir: Option<PathBuf>,
|
pub downloads_dir: Option<PathBuf>,
|
||||||
pub notify_cmd: Option<String>,
|
pub notify_cmd: Option<String>,
|
||||||
|
pub signature: Option<String>,
|
||||||
|
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub accounts: HashMap<String, Account>,
|
pub accounts: HashMap<String, Account>,
|
||||||
|
@ -170,4 +172,12 @@ impl Config {
|
||||||
|
|
||||||
Ok(())
|
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
|
// "Subject" header
|
||||||
tpl.push("Subject: ".to_string());
|
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")))
|
Ok(Tpl(tpl.join("\r\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -404,6 +416,15 @@ impl<'m> Msg<'m> {
|
||||||
.join("\r\n");
|
.join("\r\n");
|
||||||
tpl.push(thread);
|
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")))
|
Ok(Tpl(tpl.join("\r\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -489,6 +510,15 @@ impl<'m> Msg<'m> {
|
||||||
.join("\r\n");
|
.join("\r\n");
|
||||||
tpl.push(thread);
|
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")))
|
Ok(Tpl(tpl.join("\r\n")))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,6 +548,15 @@ impl<'m> Msg<'m> {
|
||||||
tpl.push("-------- Forwarded Message --------".to_string());
|
tpl.push("-------- Forwarded Message --------".to_string());
|
||||||
tpl.push(self.text_bodies("text/plain")?);
|
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")))
|
Ok(Tpl(tpl.join("\r\n")))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue