fix: expose list of nodes

This commit is contained in:
Zomatree
2025-02-17 01:48:34 +00:00
parent 367ac887f4
commit 951128032b

View File

@@ -21,11 +21,22 @@ pub struct Feature {
pub url: String, pub url: String,
} }
/// # Information about a livekit node
#[derive(Serialize, JsonSchema, Debug)]
pub struct VoiceNode {
pub name: String,
pub lat: f64,
pub lon: f64,
pub public_url: String
}
/// # Voice Server Configuration /// # Voice Server Configuration
#[derive(Serialize, JsonSchema, Debug)] #[derive(Serialize, JsonSchema, Debug)]
pub struct VoiceFeature { pub struct VoiceFeature {
/// Whether voice is enabled /// Whether voice is enabled
pub enabled: bool pub enabled: bool,
/// All livekit nodes
pub nodes: Vec<VoiceNode>,
} }
/// # Feature Configuration /// # Feature Configuration
@@ -90,20 +101,29 @@ pub async fn root() -> Result<Json<RevoltConfig>> {
features: RevoltFeatures { features: RevoltFeatures {
captcha: CaptchaFeature { captcha: CaptchaFeature {
enabled: !config.api.security.captcha.hcaptcha_key.is_empty(), enabled: !config.api.security.captcha.hcaptcha_key.is_empty(),
key: config.api.security.captcha.hcaptcha_sitekey, key: config.api.security.captcha.hcaptcha_sitekey.clone(),
}, },
email: !config.api.smtp.host.is_empty(), email: !config.api.smtp.host.is_empty(),
invite_only: config.api.registration.invite_only, invite_only: config.api.registration.invite_only,
autumn: Feature { autumn: Feature {
enabled: !config.hosts.autumn.is_empty(), enabled: !config.hosts.autumn.is_empty(),
url: config.hosts.autumn, url: config.hosts.autumn.clone(),
}, },
january: Feature { january: Feature {
enabled: !config.hosts.january.is_empty(), enabled: !config.hosts.january.is_empty(),
url: config.hosts.january, url: config.hosts.january.clone(),
}, },
livekit: VoiceFeature { livekit: VoiceFeature {
enabled: !config.hosts.livekit.is_empty() enabled: !config.hosts.livekit.is_empty(),
nodes: config.api.livekit.nodes.iter().map(|(name, value)| {
VoiceNode {
name: name.clone(),
lat: value.lat,
lon: value.lon,
public_url: config.hosts.livekit.get(name).expect("Missing corresponding host for voice node").clone()
}
})
.collect()
}, },
}, },
ws: config.hosts.events, ws: config.hosts.events,