1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2025-07-03 22:45:01 +00:00

Add "enabled" fields

This commit is contained in:
2021-10-16 17:45:25 +02:00
parent 43c76fa120
commit b7a0208e71
5 changed files with 24 additions and 4 deletions

View File

@ -18,6 +18,7 @@ pub struct DatabaseConfig {
#[derive(Debug)]
pub struct RtcRelayConfig {
pub enabled: bool,
pub ip: String,
pub token: String,
pub ice_servers: Vec<String>,
@ -28,6 +29,7 @@ pub struct RtcRelayConfig {
#[derive(Debug)]
pub struct IndependentPushService {
pub enabled: bool,
pub control_url: String,
pub control_token: String,
pub public_url: String,
@ -115,6 +117,7 @@ impl Config {
let rtc_config = match parsed_rtc.is_badvalue() {
true => None,
false => Some(RtcRelayConfig {
enabled: Config::yaml_bool(parsed_rtc, "enabled"),
ip: Config::yaml_str(parsed_rtc, "ip"),
token: Config::yaml_str(parsed_rtc, "token"),
ice_servers: parsed_rtc["ice-servers"].as_vec().unwrap().iter().map(|f| f.as_str().unwrap().to_string()).collect(),
@ -130,6 +133,7 @@ impl Config {
let independent_push_service = match parsed_independent_push_service.is_badvalue() {
true => None,
false => Some(IndependentPushService {
enabled: Config::yaml_bool(parsed_independent_push_service, "enabled"),
control_url: Config::yaml_str(parsed_independent_push_service, "control-url"),
control_token: Config::yaml_str(parsed_independent_push_service, "control-token"),
public_url: Config::yaml_str(parsed_independent_push_service, "public-url"),
@ -190,9 +194,16 @@ impl Config {
format!("{}:{}", self.listen_address, self.port)
}
/// Check if rtc relay is enabled
pub fn is_rtc_relay_enabled(&self) -> bool {
self.rtc_relay.is_some()
&& self.rtc_relay.as_ref().unwrap().enabled
}
/// Check if independent push notifications service is enabled
pub fn is_independent_push_notifications_service_enabled(&self) -> bool {
self.independent_push_service.is_some()
&& self.independent_push_service.as_ref().unwrap().enabled
}
}