mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-07-10 03:52:49 +00:00
Can get the posts of a group
This commit is contained in:
src
@ -9,6 +9,7 @@ import { SurveyController } from "./SurveyController";
|
||||
import { LikesHelper, LikesType } from "../helpers/LikesHelper";
|
||||
import { CommentsHelper } from "../helpers/CommentsHelper";
|
||||
import { CommentsController } from "./CommentsController";
|
||||
import { GroupsAccessLevel } from "../entities/Group";
|
||||
|
||||
/**
|
||||
* Posts controller
|
||||
@ -46,6 +47,31 @@ export class PostsController {
|
||||
|
||||
const posts = await PostsHelper.GetUserPosts(h.optionnalUserID, userID, startFrom);
|
||||
|
||||
await this.SendMultiplePosts(h, posts);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of posts of a group
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async GetListGroup(h: RequestHandler) {
|
||||
const groupID = await h.postGroupIDWithAccess("groupID", GroupsAccessLevel.VIEW_ACCESS);
|
||||
const startFrom = h.postInt("startFrom", 0);
|
||||
|
||||
const posts = await PostsHelper.GetGroupPosts(h.optionnalUserID, groupID, startFrom);
|
||||
|
||||
await this.SendMultiplePosts(h, posts);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Send multiple posts to the API
|
||||
*
|
||||
* @param h Request handler
|
||||
* @param posts The list of post to send
|
||||
*/
|
||||
private static async SendMultiplePosts(h: RequestHandler, posts: Array<Post>) {
|
||||
let list = [];
|
||||
for (const p of posts) {
|
||||
list.push(await this.PostToAPI(h, p));
|
||||
|
@ -186,6 +186,8 @@ export const Routes : Route[] = [
|
||||
// Posts controller
|
||||
{path: "/posts/get_user", cb: (h) => PostsController.GetListUser(h), needLogin: false},
|
||||
|
||||
{path: "/posts/get_group", cb: (h) => PostsController.GetListGroup(h), needLogin: false},
|
||||
|
||||
|
||||
|
||||
// Notifications controller
|
||||
|
Reference in New Issue
Block a user