1
0
mirror of https://gitlab.com/comunic/comunicapiv3 synced 2024-11-22 21:39:21 +00:00

Get calls configuration

This commit is contained in:
Pierre HUBERT 2021-02-08 18:24:28 +01:00
parent 01b83dfa8f
commit 8cfd10c21c
5 changed files with 44 additions and 3 deletions

View File

@ -56,4 +56,5 @@ pub mod language_settings_api;
pub mod security_settings_api;
pub mod account_image_settings_api;
pub mod res_create_custom_emoji;
pub mod res_get_ws_token;
pub mod res_get_ws_token;
pub mod user_calls_config;

View File

@ -0,0 +1,19 @@
//! # User side calls configuration
//!
//! @author Pierre Hubert
use serde::Serialize;
use crate::data::config::RtcRelayConfig;
#[derive(Serialize)]
#[allow(non_snake_case)]
pub struct UserCallsConfig {
iceServers: Vec<String>,
}
impl UserCallsConfig {
pub fn new(conf: &RtcRelayConfig) -> Self {
Self { iceServers: conf.ice_servers.clone() }
}
}

View File

@ -4,13 +4,29 @@
use std::collections::HashMap;
use crate::api_data::user_calls_config::UserCallsConfig;
use crate::controllers::routes::RequestResult;
use crate::data::base_request_handler::BaseRequestHandler;
use crate::data::config::conf;
use crate::data::error::ExecError;
use crate::data::http_request_handler::HttpRequestHandler;
use crate::data::user_ws_request_handler::UserWsRequestHandler;
/// Get legacy call configuration
pub fn get_legacy_config(r: &mut HttpRequestHandler) -> RequestResult {
let mut map = HashMap::new();
map.insert("enabled", false);
r.set_response(map)
}
/// Get calls configuration
pub fn get_config(r: &mut UserWsRequestHandler) -> RequestResult {
// TODO : check whether the user is the member of a call or not
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!"))
}

View File

@ -79,6 +79,8 @@ impl StreamHandler<Result<actix_web_actors::ws::Message, actix_web_actors::ws::P
if conf().verbose_mode {
println!("RTC RELAY WS MESSAGE: {:?}", msg);
}
// TODO : handle messages
}
}

View File

@ -2,7 +2,7 @@
//!
//! @author Pierre Hubert
use crate::controllers::{likes_controller, user_ws_actions};
use crate::controllers::{calls_controller, likes_controller, user_ws_actions};
use crate::data::error::Res;
use crate::data::user_ws_request_handler::UserWsRequestHandler;
@ -35,7 +35,10 @@ pub fn get_user_ws_routes() -> Vec<UserWsRoute> {
UserWsRoute::new("$main/unregister_post", user_ws_actions::unregister_post),
// Likes controller
UserWsRoute::new("likes/update", likes_controller::update)
UserWsRoute::new("likes/update", likes_controller::update),
// Calls controller
UserWsRoute::new("calls/config", calls_controller::get_config),
]
}