fix bug with friends method when you can add non-existing or deleted users and yourself

This commit is contained in:
veselcraft 2020-11-01 04:17:04 -05:00
parent 1e5e9d7080
commit 991e377e16

View file

@ -73,6 +73,12 @@ final class Friends extends VKAPIRequestHandler
$user = $users->get(intval($user_id));
if(is_null($user)){
$this->fail(177, "Cannot add this user to friends as user not found");
} else if($user->getId() == $this->getUser()->getId()) {
$this->fail(174, "Cannot add user himself as friend");
}
switch ($user->getSubscriptionStatus($this->getUser())) {
case 0:
$user->toggleSubscription($this->getUser());