From d1a6a16a08c858aea3fc8375905ce66496a9ef11 Mon Sep 17 00:00:00 2001 From: Finn Date: Thu, 17 Oct 2024 00:15:41 -0700 Subject: [PATCH] matrix password can be an env var --- src/config.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/config.rs b/src/config.rs index b483c54..fc7989f 100644 --- a/src/config.rs +++ b/src/config.rs @@ -11,6 +11,7 @@ pub(crate) struct Config { #[derive(serde::Deserialize, Debug)] pub(crate) struct MatrixConfig { pub(crate) username: String, + #[serde(default = "get_matrix_password")] pub(crate) password: String, #[serde(default = "get_device_name")] pub(crate) device_name: String, @@ -30,6 +31,13 @@ fn get_db_uri() -> String { "sqlite://matrix-meshtastic-bridge.db".to_string() } +fn get_matrix_password() -> String { + match std::env::var("MATRIX_PASSWORD") { + Ok(p) => p, + Err(_) => "".to_string(), + } +} + pub(crate) async fn read_config() -> Config { let filename = match std::env::var("CONFIG_PATH") { Ok(value) => value,