- introduce and test BccSelf config, to prevent bcc-self on outgoing mails

- introduce context.get_config_int() which respects default values
  declared in config.rs (Config)
This commit is contained in:
holger krekel
2019-10-02 20:15:12 +02:00
parent 489cdd1b24
commit 92438737c9
5 changed files with 55 additions and 40 deletions

View File

@@ -30,6 +30,8 @@ pub enum Config {
Selfstatus,
Selfavatar,
#[strum(props(default = "1"))]
BccSelf,
#[strum(props(default = "1"))]
E2eeEnabled,
#[strum(props(default = "1"))]
MdnsEnabled,
@@ -92,6 +94,14 @@ impl Context {
}
}
pub fn get_config_int(&self, key: Config) -> i32 {
self.get_config(key).and_then(|s| s.parse().ok()).unwrap()
}
pub fn get_config_bool(&self, key: Config) -> bool {
self.get_config_int(key) != 0
}
/// Set the given config key.
/// If `None` is passed as a value the value is cleared and set to the default if there is one.
pub fn set_config(&self, key: Config, value: Option<&str>) -> Result<(), Error> {