mirror of
https://github.com/chatmail/core.git
synced 2026-04-20 15:06:30 +03:00
Support non-persistent configuration with DELTACHAT_* env #3986
This way we can test some recently added config options that we don't want to expose in UI like DeleteToTrash or SignUnencrypted. Note that persistent config options like DeleteToTrash should remain anyway because they allow fine-grained (per-account) control. Having them matters for tests also.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
//! # Key-value configuration management.
|
||||
|
||||
use std::env;
|
||||
use std::str::FromStr;
|
||||
|
||||
use anyhow::{ensure, Context as _, Result};
|
||||
@@ -317,6 +318,11 @@ impl Context {
|
||||
|
||||
/// Get a configuration key. Returns `None` if no value is set, and no default value found.
|
||||
pub async fn get_config(&self, key: Config) -> Result<Option<String>> {
|
||||
let env_key = format!("DELTACHAT_{}", key.as_ref().to_uppercase());
|
||||
if let Ok(value) = env::var(env_key) {
|
||||
return Ok(Some(value));
|
||||
}
|
||||
|
||||
let value = match key {
|
||||
Config::Selfavatar => {
|
||||
let rel_path = self.sql.get_raw_config(key.as_ref()).await?;
|
||||
|
||||
Reference in New Issue
Block a user