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;
|
namespace openvk\VKAPI\Handlers;
|
||||||
use openvk\Web\Models\Entities\User;
|
use openvk\Web\Models\Entities\User;
|
||||||
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
use openvk\Web\Models\Repositories\Users as UsersRepo;
|
||||||
|
use openvk\Web\Models\Repositories\Blacklists;
|
||||||
|
|
||||||
final class Users extends VKAPIRequestHandler
|
final class Users extends VKAPIRequestHandler
|
||||||
{
|
{
|
||||||
|
@ -40,13 +41,14 @@ final class Users extends VKAPIRequestHandler
|
||||||
"id" => $usr->getId(),
|
"id" => $usr->getId(),
|
||||||
"first_name" => $usr->getFirstName(),
|
"first_name" => $usr->getFirstName(),
|
||||||
"last_name" => $usr->getLastName(),
|
"last_name" => $usr->getLastName(),
|
||||||
"is_closed" => false,
|
"is_closed" => (new Blacklists)->isBanned($usr, $authuser),
|
||||||
"can_access_closed" => true,
|
"can_access_closed" => !(new Blacklists)->isBanned($usr, $authuser),
|
||||||
];
|
];
|
||||||
|
|
||||||
$flds = explode(',', $fields);
|
$flds = explode(',', $fields);
|
||||||
|
|
||||||
foreach($flds as $field) {
|
if (!(new Blacklists)->isBanned($usr, $authuser))
|
||||||
|
foreach($flds as $field) {
|
||||||
switch($field) {
|
switch($field) {
|
||||||
case "verified":
|
case "verified":
|
||||||
$response[$i]->verified = intval($usr->isVerified());
|
$response[$i]->verified = intval($usr->isVerified());
|
||||||
|
@ -134,6 +136,7 @@ final class Users extends VKAPIRequestHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!(new Blacklists)->isBanned($usr, $authuser))
|
||||||
if($usr->getOnline()->timestamp() + 300 > time())
|
if($usr->getOnline()->timestamp() + 300 > time())
|
||||||
$response[$i]->online = 1;
|
$response[$i]->online = 1;
|
||||||
else
|
else
|
||||||
|
@ -153,8 +156,14 @@ final class Users extends VKAPIRequestHandler
|
||||||
$users = new UsersRepo;
|
$users = new UsersRepo;
|
||||||
|
|
||||||
$this->requireUser();
|
$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();
|
$followers[] = $follower->getId();
|
||||||
|
|
||||||
$response = $followers;
|
$response = $followers;
|
||||||
|
@ -163,7 +172,7 @@ final class Users extends VKAPIRequestHandler
|
||||||
$response = $this->get(implode(',', $followers), $fields, 0, $count);
|
$response = $this->get(implode(',', $followers), $fields, 0, $count);
|
||||||
|
|
||||||
return (object) [
|
return (object) [
|
||||||
"count" => $users->get($user_id)->getFollowersCount(),
|
"count" => $target->getFollowersCount(),
|
||||||
"items" => $response
|
"items" => $response
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue