mirror of
https://github.com/openvk/openvk
synced 2024-12-22 16:42:32 +03:00
[API] Fix null user in Likes.isLiked + requireUser in some funcs + return 1 in Polls (#801)
* Fix returning 200 response for non-existing user * requireUser in getCounters and createComment * return 1, where it should in Polls API
This commit is contained in:
parent
803a57ef4b
commit
12c41dcdd6
3 changed files with 5 additions and 7 deletions
|
@ -66,6 +66,8 @@ final class Account extends VKAPIRequestHandler
|
|||
|
||||
function getCounters(string $filter = ""): object
|
||||
{
|
||||
$this->requireUser();
|
||||
|
||||
return (object) [
|
||||
"friends" => $this->getUser()->getFollowersCount(),
|
||||
"notifications" => $this->getUser()->getNotificationsCount(),
|
||||
|
|
|
@ -54,11 +54,7 @@ final class Likes extends VKAPIRequestHandler
|
|||
case "post":
|
||||
$user = (new UsersRepo)->get($user_id);
|
||||
if (is_null($user))
|
||||
return (object) [
|
||||
"liked" => 0,
|
||||
"copied" => 0,
|
||||
"sex" => 0
|
||||
];
|
||||
$this->fail(100, "One of the parameters specified was missing or invalid: user not found");
|
||||
|
||||
$post = (new PostsRepo)->getPostById($owner_id, $item_id);
|
||||
if (is_null($post))
|
||||
|
|
|
@ -75,7 +75,7 @@ final class Polls extends VKAPIRequestHandler
|
|||
|
||||
try {
|
||||
$poll->vote($this->getUser(), explode(",", $answers_ids));
|
||||
return 0;
|
||||
return 1;
|
||||
} catch(AlreadyVotedException $ex) {
|
||||
return 0;
|
||||
} catch(PollLockedException $ex) {
|
||||
|
@ -97,7 +97,7 @@ final class Polls extends VKAPIRequestHandler
|
|||
|
||||
try {
|
||||
$poll->revokeVote($this->getUser());
|
||||
return 0;
|
||||
return 1;
|
||||
} catch(PollLockedException $ex) {
|
||||
$this->fail(15, "Access denied: Poll is locked or isn't revotable");
|
||||
} catch(InvalidOptionException $ex) {
|
||||
|
|
Loading…
Reference in a new issue