mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-25 23:09:22 +00:00
Add "enabled" fields
This commit is contained in:
parent
43c76fa120
commit
b7a0208e71
@ -41,6 +41,8 @@ verbose-mode: true
|
||||
|
||||
# Independent push notification service information
|
||||
independent-push-service:
|
||||
enabled: true
|
||||
|
||||
# Server access (to create clients and push notifications)
|
||||
control-url: http://localhost:4500/
|
||||
control-token: BADTOKENTOCHANGE
|
||||
@ -62,6 +64,7 @@ database:
|
||||
|
||||
# Video calls configuration
|
||||
rtc-relay:
|
||||
enabled: true
|
||||
ip: 127.0.0.1
|
||||
token: SecretToken
|
||||
ice-servers:
|
||||
|
@ -94,9 +94,11 @@ pub fn get_config(r: &mut UserWsRequestHandler) -> RequestResult {
|
||||
r.forbidden("You do not belong to any call yet!".to_string())?;
|
||||
}
|
||||
|
||||
if let Some(conf) = conf().rtc_relay.as_ref()
|
||||
{
|
||||
return r.set_response(UserCallsConfig::new(conf));
|
||||
if conf().is_rtc_relay_enabled() {
|
||||
if let Some(conf) = conf().rtc_relay.as_ref()
|
||||
{
|
||||
return r.set_response(UserCallsConfig::new(conf));
|
||||
}
|
||||
}
|
||||
|
||||
r.internal_error(ExecError::boxed_new("Missing calls configuration!"))
|
||||
|
@ -237,7 +237,7 @@ pub async fn open_ws(req: actix_web::HttpRequest,
|
||||
let ip = req.peer_addr().unwrap();
|
||||
|
||||
// Check if video calls are enabled
|
||||
if conf().rtc_relay.is_none() {
|
||||
if !conf().is_rtc_relay_enabled() {
|
||||
eprintln!("A relay from {} tried to connect to the server but the relay is disabled!", ip);
|
||||
return Ok(actix_web::HttpResponse::BadRequest().body("RTC Relay not configured!"));
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,10 @@ use crate::data::conversation::Conversation;
|
||||
|
||||
/// Check out whether a conversation can make a call or not
|
||||
pub fn can_have_call(conv: &Conversation) -> bool {
|
||||
if !conf().is_rtc_relay_enabled() {
|
||||
return false;
|
||||
}
|
||||
|
||||
if let Some(conf) = &conf().rtc_relay {
|
||||
return conv.members.len() > 1
|
||||
&& conf.max_users_per_calls >= conv.members.len() as u64
|
||||
|
Loading…
Reference in New Issue
Block a user