mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 00:25:18 +00:00
Can get a user membership
This commit is contained in:
@ -412,6 +412,30 @@ class GroupsController {
|
||||
return array("success" => "The response to the request has been successfully saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get information about a membership
|
||||
*
|
||||
* @url POST /groups/get_membership
|
||||
*/
|
||||
public function getMembership() : array {
|
||||
|
||||
//Get the ID of the target group
|
||||
$groupID = getPostGroupIdWithAccess("groupID", GroupInfo::MODERATOR_ACCESS);
|
||||
|
||||
//Get user ID
|
||||
$userID = getPostUserID("userID");
|
||||
|
||||
//Check if the user has a membership or not
|
||||
if(!components()->groups->hasMembership($userID, $groupID))
|
||||
Rest_fatal_error(404, "Specified user does not have any membership in this group!");
|
||||
|
||||
//Get user membership
|
||||
$membership = components()->groups->getMembership($userID, $groupID);
|
||||
|
||||
//Parse and return result
|
||||
return self::GroupMemberToAPI($membership);
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a GroupInfo object into an array for the API
|
||||
*
|
||||
|
Reference in New Issue
Block a user