mirror of
https://github.com/pierre42100/ComunicAPI
synced 2025-06-18 16:18:04 +00:00
Can remove a previously sent frienship request.
This commit is contained in:
@ -66,6 +66,33 @@ class friendsController{
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a previously send frienship request
|
||||
*
|
||||
* @url POST /friends/removeRequest
|
||||
*/
|
||||
public function removeRequest(){
|
||||
user_login_required(); //Login required
|
||||
|
||||
//Check parametres
|
||||
if(!isset($_POST["friendID"]))
|
||||
Rest_fatal_error(400, "Please specify a user ID !");
|
||||
|
||||
//Extract informations and process request
|
||||
$friendID = toInt($_POST['friendID']);
|
||||
|
||||
//Check if the current user has sent a request to the other user
|
||||
if(!CS::get()->components->friends->sent_request(userID, $friendID))
|
||||
Rest_fatal_error(401, "You didn't send a friendship request to this user !");
|
||||
|
||||
//Try to remove the friendship request
|
||||
if(!CS::get()->components->friends->remove_request(userID, $friendID))
|
||||
Rest_fatal_error(500, "An error occured while trying to remove the friendship request !");
|
||||
|
||||
//This is a success
|
||||
return array("success" => "The friendship request has been removed!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Respond to a friendship request
|
||||
*
|
||||
|
Reference in New Issue
Block a user