mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 16:35:17 +00:00
Can get the latest posts
This commit is contained in:
@ -35,7 +35,7 @@ pub fn create(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
|
||||
/// Get the list of groups of the current user
|
||||
pub fn get_list_user(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let list = groups_helper::get_list_user(r.user_id()?, false)?
|
||||
let list = groups_helper::get_list_user(r.user_id_ref()?, false)?
|
||||
.iter()
|
||||
.map(|f| f.id())
|
||||
.collect::<Vec<u64>>();
|
||||
|
@ -33,5 +33,17 @@ pub fn get_list_group(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
.set_start_from(start_from)
|
||||
.get_group(&group_id)?;
|
||||
|
||||
r.set_response(PostAPI::for_list(&posts, r.user_id_opt())?)
|
||||
}
|
||||
|
||||
/// Get the latest posts of a group
|
||||
pub fn get_latest(r: &mut HttpRequestHandler) -> RequestResult {
|
||||
let start_from = r.post_u64_opt("startFrom", 0)?;
|
||||
let include_groups = r.post_bool_opt("include_groups", false);
|
||||
|
||||
let posts = posts_helper::PostsQuery::new(r.user_id_opt())
|
||||
.set_start_from(start_from)
|
||||
.get_latest(include_groups)?;
|
||||
|
||||
r.set_response(PostAPI::for_list(&posts, r.user_id_opt())?)
|
||||
}
|
@ -202,6 +202,8 @@ pub fn get_routes() -> Vec<Route> {
|
||||
|
||||
Route::post("/posts/get_group", Box::new(posts_controller::get_list_group)),
|
||||
|
||||
Route::post("/posts/get_latest", Box::new(posts_controller::get_latest)),
|
||||
|
||||
|
||||
// Virtual directory controller
|
||||
Route::post("/user/findbyfolder", Box::new(virtual_directory_controller::find_user)),
|
||||
|
Reference in New Issue
Block a user