From 4ba7c5b9823b72466935f9ecebf4809770593a7b Mon Sep 17 00:00:00 2001 From: veselcraft Date: Sun, 31 Jul 2022 13:25:00 +0300 Subject: [PATCH] VKAPI: Fix privacy issues Closes #622 --- VKAPI/Handlers/Users.php | 2 +- VKAPI/Handlers/Wall.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/VKAPI/Handlers/Users.php b/VKAPI/Handlers/Users.php index 3237998f..30d220d6 100644 --- a/VKAPI/Handlers/Users.php +++ b/VKAPI/Handlers/Users.php @@ -25,7 +25,7 @@ final class Users extends VKAPIRequestHandler for($i=0; $i < $ic; $i++) { $usr = $users->get((int) $usrs[$i]); - if(is_null($usr)) { + if(is_null($usr) || $usr->isDeleted()) { $response[$i] = (object)[ "id" => $usrs[$i], "first_name" => "DELETED", diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index c4cb9729..cb4720dc 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -12,16 +12,21 @@ use openvk\Web\Models\Repositories\Comments as CommentsRepo; final class Wall extends VKAPIRequestHandler { - function get(string $owner_id, string $domain = "", int $offset = 0, int $count = 30, int $extended = 0): object + function get(int $owner_id, string $domain = "", int $offset = 0, int $count = 30, int $extended = 0): object { $posts = new PostsRepo; $items = []; $profiles = []; $groups = []; - $count = $posts->getPostCountOnUserWall((int) $owner_id); + $count = $posts->getPostCountOnUserWall($owner_id); - foreach($posts->getPostsFromUsersWall((int)$owner_id, 1, $count, $offset) as $post) { + $wallOnwer = (new UsersRepo)->get($owner_id); + + if(!$wallOnwer || $wallOnwer->isDeleted() || $wallOnwer->isDeleted()) + $this->fail(18, "User was deleted or banned"); + + foreach($posts->getPostsFromUsersWall($owner_id, 1, $count, $offset) as $post) { $from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId(); $attachments = [];