mirror of
https://github.com/openvk/openvk
synced 2024-12-23 09:01:15 +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
|
function getCounters(string $filter = ""): object
|
||||||
{
|
{
|
||||||
|
$this->requireUser();
|
||||||
|
|
||||||
return (object) [
|
return (object) [
|
||||||
"friends" => $this->getUser()->getFollowersCount(),
|
"friends" => $this->getUser()->getFollowersCount(),
|
||||||
"notifications" => $this->getUser()->getNotificationsCount(),
|
"notifications" => $this->getUser()->getNotificationsCount(),
|
||||||
|
|
|
@ -54,11 +54,7 @@ final class Likes extends VKAPIRequestHandler
|
||||||
case "post":
|
case "post":
|
||||||
$user = (new UsersRepo)->get($user_id);
|
$user = (new UsersRepo)->get($user_id);
|
||||||
if (is_null($user))
|
if (is_null($user))
|
||||||
return (object) [
|
$this->fail(100, "One of the parameters specified was missing or invalid: user not found");
|
||||||
"liked" => 0,
|
|
||||||
"copied" => 0,
|
|
||||||
"sex" => 0
|
|
||||||
];
|
|
||||||
|
|
||||||
$post = (new PostsRepo)->getPostById($owner_id, $item_id);
|
$post = (new PostsRepo)->getPostById($owner_id, $item_id);
|
||||||
if (is_null($post))
|
if (is_null($post))
|
||||||
|
|
|
@ -75,7 +75,7 @@ final class Polls extends VKAPIRequestHandler
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$poll->vote($this->getUser(), explode(",", $answers_ids));
|
$poll->vote($this->getUser(), explode(",", $answers_ids));
|
||||||
return 0;
|
return 1;
|
||||||
} catch(AlreadyVotedException $ex) {
|
} catch(AlreadyVotedException $ex) {
|
||||||
return 0;
|
return 0;
|
||||||
} catch(PollLockedException $ex) {
|
} catch(PollLockedException $ex) {
|
||||||
|
@ -97,7 +97,7 @@ final class Polls extends VKAPIRequestHandler
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$poll->revokeVote($this->getUser());
|
$poll->revokeVote($this->getUser());
|
||||||
return 0;
|
return 1;
|
||||||
} catch(PollLockedException $ex) {
|
} catch(PollLockedException $ex) {
|
||||||
$this->fail(15, "Access denied: Poll is locked or isn't revotable");
|
$this->fail(15, "Access denied: Poll is locked or isn't revotable");
|
||||||
} catch(InvalidOptionException $ex) {
|
} catch(InvalidOptionException $ex) {
|
||||||
|
|
Loading…
Reference in a new issue