Add 'euph.rooms.<name>.password' config option

This commit is contained in:
Joscha 2022-08-25 22:49:34 +02:00
parent e40948567a
commit 6e6fddc0b1
7 changed files with 65 additions and 12 deletions

View file

@ -1,3 +1,4 @@
use std::collections::HashMap;
use std::fs;
use std::path::{Path, PathBuf};
@ -5,11 +6,22 @@ use serde::Deserialize;
use crate::macros::ok_or_return;
#[derive(Debug, Clone, Default, Deserialize)]
pub struct EuphRoom {
pub password: Option<String>,
}
#[derive(Debug, Default, Deserialize)]
pub struct Euph {
pub rooms: HashMap<String, EuphRoom>,
}
#[derive(Debug, Default, Deserialize)]
pub struct Config {
pub data_dir: Option<PathBuf>,
#[serde(default)]
pub ephemeral: bool,
pub euph: Euph,
}
impl Config {
@ -23,4 +35,8 @@ impl Config {
}
}
}
pub fn euph_room(&self, name: &str) -> EuphRoom {
self.euph.rooms.get(name).cloned().unwrap_or_default()
}
}