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,