mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2024-11-25 23:09:22 +00:00
Can get advanced information about Forez group member
This commit is contained in:
parent
c177c2c2f6
commit
f34310733a
26
src/api_data/forez_member_api.rs
Normal file
26
src/api_data/forez_member_api.rs
Normal file
@ -0,0 +1,26 @@
|
||||
//! #Forez member information
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::api_data::group_member_api::GroupMemberAPI;
|
||||
use crate::api_data::user_info::{APIAdvancedInfo, APIUserInfo};
|
||||
use crate::data::error::Res;
|
||||
use crate::data::group_member::GroupMember;
|
||||
use crate::data::user::{User, UserID};
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct ForezMemberAPI {
|
||||
user: APIAdvancedInfo,
|
||||
membership: GroupMemberAPI,
|
||||
}
|
||||
|
||||
impl ForezMemberAPI {
|
||||
pub fn new(user: &User, membership: &GroupMember, request_from: UserID) -> Res<Self> {
|
||||
Ok(Self {
|
||||
user: APIUserInfo::new_advanced_info(&Some(request_from.clone()), user)?,
|
||||
membership: GroupMemberAPI::new(membership),
|
||||
})
|
||||
}
|
||||
}
|
@ -70,4 +70,5 @@ pub mod removed_user_from_conv_message;
|
||||
pub mod user_is_writing_message_in_conversation;
|
||||
pub mod res_create_conversation_for_group;
|
||||
pub mod notification_settings_api;
|
||||
pub mod push_notifications_status_api;
|
||||
pub mod push_notifications_status_api;
|
||||
pub mod forez_member_api;
|
@ -5,13 +5,14 @@
|
||||
//!
|
||||
//! @author Pierre Hubert
|
||||
|
||||
use crate::api_data::forez_member_api::ForezMemberAPI;
|
||||
use crate::api_data::group_api::GroupApi;
|
||||
use crate::data::base_request_handler::BaseRequestHandler;
|
||||
use crate::data::config::conf;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::data::presence::Presence;
|
||||
use crate::data::user_ws_request_handler::UserWsRequestHandler;
|
||||
use crate::helpers::{forez_presence_helper, groups_helper};
|
||||
use crate::helpers::{forez_presence_helper, groups_helper, user_helper};
|
||||
use crate::routes::RequestResult;
|
||||
|
||||
/// Get the list of declared Forez groups in the application
|
||||
@ -25,6 +26,21 @@ pub fn get_list_groups(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
r.set_response(list)
|
||||
}
|
||||
|
||||
/// Get advanced information about all the members of a group
|
||||
pub fn get_members_info(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let group = r.post_forez_group("group")?;
|
||||
|
||||
let members = groups_helper::get_list_members(&group)?;
|
||||
let mut users = vec![];
|
||||
|
||||
for member in members {
|
||||
let user = user_helper::find_user_by_id(&member.user_id)?;
|
||||
users.push(ForezMemberAPI::new(&user, &member, r.user_id()?)?);
|
||||
}
|
||||
|
||||
r.set_response(users)
|
||||
}
|
||||
|
||||
/// Set presence
|
||||
///
|
||||
/// Presences format: YYYY,MM,DD;YYYY,MM,DD;...
|
||||
|
@ -300,5 +300,6 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
// Forez controller
|
||||
Route::post("/forez/get_groups", Box::new(forez_controller::get_list_groups)),
|
||||
Route::post("/forez/get_members_info", Box::new(forez_controller::get_members_info)),
|
||||
]
|
||||
}
|
Loading…
Reference in New Issue
Block a user