Can get the posts of a group and returns them to the API

This commit is contained in:
Pierre HUBERT
2018-07-16 15:06:23 +02:00
parent cd772c03c3
commit 2d820403f5
3 changed files with 83 additions and 4 deletions

View File

@ -56,6 +56,31 @@ class PostsController {
return $this->parsePostsList($posts);
}
/**
* Get group posts
*
* @url POST /posts/get_group
*/
public function getGroupPosts(){
//Get group ID
$groupID = getPostGroupIdWithAccess("groupID", GroupInfo::VIEW_ACCESS);
//Get the startpoint for the posts
$startFrom = postInt("startFrom", 0);
//Check whether the user can see members only posts or not
$membershipLevel = components()->groups->getMembershipLevel(userID, $groupID);
$seeAllPosts = $membershipLevel <= GroupMember::MEMBER;
//Get the posts of the group
$posts = components()->posts->getGroupPosts($groupID, $seeAllPosts, $startFrom);
//Return parsed list of posts
return $this->parsePostsList($posts);
}
/**
* Get the latest posts for the user
*