mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-19 16:45:17 +00:00
Can cancel a membership request.
This commit is contained in:
@ -260,6 +260,29 @@ class GroupsController {
|
||||
return array("success" => "The response to the invitation was saved!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancel a membership request
|
||||
*
|
||||
* @url POST /groups/cancel_request
|
||||
*/
|
||||
public function cancelRequest(){
|
||||
|
||||
user_login_required();
|
||||
|
||||
//Get the ID of the group (with basic access)
|
||||
$groupID = getPostGroupIdWithAccess("id", GroupInfo::LIMITED_ACCESS);
|
||||
|
||||
//Check if the user has created a membership request
|
||||
if(components()->groups->getMembershipLevel(userID, $groupID) != GroupMember::PENDING)
|
||||
Rest_fatal_error(401, "You did not send a membership request to this group!");
|
||||
|
||||
//Try to cancel membership request
|
||||
if(!components()->groups->cancelRequest(userID, $groupID))
|
||||
Rest_fatal_error(500, "An error occurred while trying to cancel membership request!");
|
||||
|
||||
return array("success" => "The request has been successfully cancelled!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse a GroupInfo object into an array for the API
|
||||
*
|
||||
|
Reference in New Issue
Block a user