Can cancel a membership request.

This commit is contained in:
Pierre HUBERT
2018-07-06 18:36:19 +02:00
parent c3bdbedb30
commit cd8fc40810
2 changed files with 51 additions and 5 deletions

View File

@ -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
*