Support domain in config file
This commit is contained in:
parent
c094f526a5
commit
5995d06cad
3 changed files with 41 additions and 36 deletions
|
|
@ -35,7 +35,13 @@ pub struct EuphRoom {
|
|||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Document)]
|
||||
pub struct Euph {
|
||||
pub struct EuphServer {
|
||||
#[document(metavar = "room")]
|
||||
pub rooms: HashMap<String, EuphRoom>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Default, Deserialize, Document)]
|
||||
pub struct Euph {
|
||||
#[document(metavar = "domain")]
|
||||
pub servers: HashMap<String, EuphServer>,
|
||||
}
|
||||
|
|
|
|||
|
|
@ -107,7 +107,12 @@ impl Config {
|
|||
})
|
||||
}
|
||||
|
||||
pub fn euph_room(&self, name: &str) -> EuphRoom {
|
||||
self.euph.rooms.get(name).cloned().unwrap_or_default()
|
||||
pub fn euph_room(&self, domain: &str, name: &str) -> EuphRoom {
|
||||
if let Some(server) = self.euph.servers.get(domain) {
|
||||
if let Some(room) = server.rooms.get(name) {
|
||||
return room.clone();
|
||||
}
|
||||
}
|
||||
EuphRoom::default()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue