matrix password can be an env var
All checks were successful
/ build-container (push) Successful in 6m4s

This commit is contained in:
Finn 2024-10-17 00:15:41 -07:00
parent 7dc750d68b
commit d1a6a16a08

View file

@ -11,6 +11,7 @@ pub(crate) struct Config {
#[derive(serde::Deserialize, Debug)] #[derive(serde::Deserialize, Debug)]
pub(crate) struct MatrixConfig { pub(crate) struct MatrixConfig {
pub(crate) username: String, pub(crate) username: String,
#[serde(default = "get_matrix_password")]
pub(crate) password: String, pub(crate) password: String,
#[serde(default = "get_device_name")] #[serde(default = "get_device_name")]
pub(crate) device_name: String, pub(crate) device_name: String,
@ -30,6 +31,13 @@ fn get_db_uri() -> String {
"sqlite://matrix-meshtastic-bridge.db".to_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 { pub(crate) async fn read_config() -> Config {
let filename = match std::env::var("CONFIG_PATH") { let filename = match std::env::var("CONFIG_PATH") {
Ok(value) => value, Ok(value) => value,