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

Can get the list of Forez groups

This commit is contained in:
Pierre HUBERT 2021-04-18 14:42:45 +02:00
parent 53446ab8a6
commit 3da9f26176
6 changed files with 49 additions and 2 deletions

View File

@ -2,6 +2,7 @@
<dictionary name="pierre"> <dictionary name="pierre">
<words> <words>
<w>comunic</w> <w>comunic</w>
<w>forez</w>
</words> </words>
</dictionary> </dictionary>
</component> </component>

View File

@ -63,3 +63,11 @@ rtc-relay:
max-users-per-calls: 10 max-users-per-calls: 10
allow-video: true allow-video: true
max-users-per-video-calls: 6 max-users-per-video-calls: 6
# List of #Forez groups
#
# This option allows to enable some extra features for these groups
#
# In most cases you should not have to specify this information
forez_groups:
- 32

View File

@ -0,0 +1,24 @@
//! # Forez controller
//!
//! This controller contains the logic specific to the integration of the #Forez application into
//! Comunic.
//!
//! @author Pierre Hubert
use crate::data::http_request_handler::HttpRequestHandler;
use crate::routes::RequestResult;
use crate::data::config::conf;
use crate::data::base_request_handler::BaseRequestHandler;
use crate::api_data::group_api::GroupApi;
use crate::helpers::groups_helper;
/// Get the list of declared Forez groups in the application
pub fn get_list_groups(r: &mut HttpRequestHandler) -> RequestResult {
let mut list = vec![];
for group in &conf().forez_groups {
list.push(GroupApi::new(&groups_helper::get_info(group)?, r.user_id_opt())?);
}
r.set_response(list)
}

View File

@ -18,3 +18,4 @@ pub mod web_app_controller;
pub mod calls_controller; pub mod calls_controller;
pub mod user_ws_actions; pub mod user_ws_actions;
pub mod push_notifications_controller; pub mod push_notifications_controller;
pub mod forez_controller;

View File

@ -2,6 +2,8 @@ use std::error::Error;
use yaml_rust::{Yaml, YamlLoader}; use yaml_rust::{Yaml, YamlLoader};
use crate::data::group_id::GroupID;
/// Server configuration /// Server configuration
/// ///
/// @author Pierre Hubert /// @author Pierre Hubert
@ -47,6 +49,7 @@ pub struct Config {
pub independent_push_service: Option<IndependentPushService>, pub independent_push_service: Option<IndependentPushService>,
pub database: DatabaseConfig, pub database: DatabaseConfig,
pub rtc_relay: Option<RtcRelayConfig>, pub rtc_relay: Option<RtcRelayConfig>,
pub forez_groups: Vec<GroupID>,
} }
/// Globally available configuration /// Globally available configuration
@ -143,6 +146,13 @@ impl Config {
database: database_conf, database: database_conf,
rtc_relay: rtc_config, rtc_relay: rtc_config,
forez_groups: parsed["forez_groups"]
.as_vec()
.unwrap_or(&vec![])
.iter()
.map(|f| GroupID::new(f.as_i64().unwrap() as u64))
.collect(),
}; };
// Save new configuration in memory // Save new configuration in memory

View File

@ -1,6 +1,6 @@
use std::error::Error; use std::error::Error;
use crate::controllers::{account_controller, comments_controller, conversations_controller, friends_controller, groups_controller, likes_controller, notifications_controller, posts_controller, push_notifications_controller, search_controller, server_controller, settings_controller, surveys_controller, user_controller, user_ws_controller, virtual_directory_controller, web_app_controller}; use crate::controllers::{account_controller, comments_controller, conversations_controller, forez_controller, friends_controller, groups_controller, likes_controller, notifications_controller, posts_controller, push_notifications_controller, search_controller, server_controller, settings_controller, surveys_controller, user_controller, user_ws_controller, virtual_directory_controller, web_app_controller};
use crate::data::http_request_handler::HttpRequestHandler; use crate::data::http_request_handler::HttpRequestHandler;
use crate::routes::Method::{GET, POST}; use crate::routes::Method::{GET, POST};
@ -297,5 +297,8 @@ pub fn get_routes() -> Vec<Route> {
// Web application controller // Web application controller
Route::post("/webApp/getMemberships", Box::new(web_app_controller::get_memberships)), Route::post("/webApp/getMemberships", Box::new(web_app_controller::get_memberships)),
// Forez controller
Route::post("/forez/get_groups", Box::new(forez_controller::get_list_groups)),
] ]
} }