diff options
author | ashelyn ghost <git@ashen.earth> | 2024-07-09 00:44:27 -0600 |
---|---|---|
committer | Ashelyn Rose <git@ashen.earth> | 2024-07-09 00:44:27 -0600 |
commit | 0b90860d730b2fbd7ebe2b9c39084edd006f515d (patch) | |
tree | 53b1294f0104056485bd45a3395a27768ff215ef /src/config.rs | |
parent | d22f2b74d8931a32da0ed970bedcb4e49f4934f7 (diff) |
autoproxy
Diffstat (limited to 'src/config.rs')
-rw-r--r-- | src/config.rs | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/config.rs b/src/config.rs index 26d3666..794e477 100644 --- a/src/config.rs +++ b/src/config.rs @@ -19,8 +19,11 @@ pub enum PresenceMode { } #[derive(Deserialize, Clone)] +#[serde(tag = "mode", rename_all = "lowercase")] pub enum AutoproxyConfig { - Member(String), + Member { + name: MemberName + }, Latch { scope: AutoproxyLatchScope, timeout_seconds: u32, @@ -29,6 +32,7 @@ pub enum AutoproxyConfig { } #[derive(Deserialize, Clone)] +#[serde(rename_all = "lowercase")] pub enum AutoproxyLatchScope { Global, Server @@ -55,9 +59,11 @@ fn default_forward_pings() -> bool { false } +pub type MemberName = String; + #[derive(Deserialize, Clone)] pub struct Member { - pub name: String, + pub name: MemberName, #[serde(with = "serde_regex")] pub message_pattern: Regex, pub discord_token: String, @@ -78,13 +84,13 @@ impl Config { config.systems.iter().for_each(|config_system| { let (system_name, system) = config_system; if let Some(autoproxy) = &system.autoproxy { - if let AutoproxyConfig::Member(autoproxy_member) = autoproxy { + if let AutoproxyConfig::Member { name } = autoproxy { let member_matches = system.members.iter().all(|member| { - member.name == *autoproxy_member + member.name == *name }); if !member_matches { - panic!("System {} autoproxy member {} does not match a known member name", system_name, autoproxy_member); + panic!("System {} autoproxy member {} does not match a known member name", system_name, name); } } } |