mirror of
https://github.com/openvk/openvk
synced 2024-11-15 11:39:13 +03:00
Added restrictions in the users.get method
This commit is contained in:
parent
82a5aaf8b8
commit
0c65856108
1 changed files with 15 additions and 6 deletions
|
@ -2,6 +2,7 @@
|
|||
namespace openvk\VKAPI\Handlers;
|
||||
use openvk\Web\Models\Entities\User;
|
||||
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
||||
use openvk\Web\Models\Repositories\Blacklists;
|
||||
|
||||
final class Users extends VKAPIRequestHandler
|
||||
{
|
||||
|
@ -40,12 +41,13 @@ final class Users extends VKAPIRequestHandler
|
|||
"id" => $usr->getId(),
|
||||
"first_name" => $usr->getFirstName(),
|
||||
"last_name" => $usr->getLastName(),
|
||||
"is_closed" => false,
|
||||
"can_access_closed" => true,
|
||||
"is_closed" => (new Blacklists)->isBanned($usr, $authuser),
|
||||
"can_access_closed" => !(new Blacklists)->isBanned($usr, $authuser),
|
||||
];
|
||||
|
||||
$flds = explode(',', $fields);
|
||||
|
||||
if (!(new Blacklists)->isBanned($usr, $authuser))
|
||||
foreach($flds as $field) {
|
||||
switch($field) {
|
||||
case "verified":
|
||||
|
@ -134,6 +136,7 @@ final class Users extends VKAPIRequestHandler
|
|||
}
|
||||
}
|
||||
|
||||
if (!(new Blacklists)->isBanned($usr, $authuser))
|
||||
if($usr->getOnline()->timestamp() + 300 > time())
|
||||
$response[$i]->online = 1;
|
||||
else
|
||||
|
@ -154,7 +157,13 @@ final class Users extends VKAPIRequestHandler
|
|||
|
||||
$this->requireUser();
|
||||
|
||||
foreach($users->get($user_id)->getFollowers($offset, $count) as $follower)
|
||||
$authuser = $this->getUser();
|
||||
$target = $users->get($user_id);
|
||||
|
||||
if ((new Blacklists)->isBanned($target, $authuser))
|
||||
$this->fail(15, "Access denied: User is blacklisted");
|
||||
|
||||
foreach($target->getFollowers($offset, $count) as $follower)
|
||||
$followers[] = $follower->getId();
|
||||
|
||||
$response = $followers;
|
||||
|
@ -163,7 +172,7 @@ final class Users extends VKAPIRequestHandler
|
|||
$response = $this->get(implode(',', $followers), $fields, 0, $count);
|
||||
|
||||
return (object) [
|
||||
"count" => $users->get($user_id)->getFollowersCount(),
|
||||
"count" => $target->getFollowersCount(),
|
||||
"items" => $response
|
||||
];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue