mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Can get group's posts
This commit is contained in:
@ -4,6 +4,7 @@
|
||||
|
||||
use crate::api_data::post_api::PostAPI;
|
||||
use crate::controllers::routes::RequestResult;
|
||||
use crate::data::group::GroupAccessLevel;
|
||||
use crate::data::http_request_handler::HttpRequestHandler;
|
||||
use crate::helpers::{posts_helper, user_helper};
|
||||
|
||||
@ -20,5 +21,17 @@ pub fn get_list_user(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
.set_start_from(start_from)
|
||||
.get_user(&user_id)?;
|
||||
|
||||
r.set_response(PostAPI::for_list(&posts, r.user_id_opt())?)
|
||||
}
|
||||
|
||||
/// Get the list of posts of a group
|
||||
pub fn get_list_group(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let group_id = r.post_group_id_with_access("groupID", GroupAccessLevel::VIEW_ACCESS)?;
|
||||
let start_from = r.post_u64_opt("startFrom", 0)?;
|
||||
|
||||
let posts = posts_helper::PostsQuery::new(r.user_id_opt())
|
||||
.set_start_from(start_from)
|
||||
.get_group(&group_id)?;
|
||||
|
||||
r.set_response(PostAPI::for_list(&posts, r.user_id_opt())?)
|
||||
}
|
@ -196,9 +196,12 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/groups/delete", Box::new(groups_controller::delete_group)),
|
||||
|
||||
|
||||
// Posts controller
|
||||
Route::post("/posts/get_user", Box::new(posts_controller::get_list_user)),
|
||||
|
||||
Route::post("/posts/get_group", Box::new(posts_controller::get_list_group)),
|
||||
|
||||
|
||||
// Virtual directory controller
|
||||
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),
|
||||
|
Reference in New Issue
Block a user