mirror of
https://github.com/chatmail/core.git
synced 2026-04-26 01:46:34 +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:
@@ -6,6 +6,7 @@
|
||||
- Drop unused SQL columns #4141
|
||||
- "full message view" not needed because of footers that go to contact status #4151
|
||||
- Pick up system's light/dark mode in generated message HTML #4150
|
||||
- Support non-persistent configuration with DELTACHAT_* env
|
||||
|
||||
### Fixes
|
||||
- Fix segmentation fault if `dc_context_unref()` is called during
|
||||
|
||||
@@ -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