VKAPI: Fix Groups.get unworkability if owner id is less than zero

This commit is contained in:
veselcraft 2022-10-11 03:22:32 +03:00
parent da41006ddb
commit 307b7709cc
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -10,7 +10,7 @@ final class Groups extends VKAPIRequestHandler
$this->requireUser(); $this->requireUser();
if($user_id == 0) { if($user_id == 0) {
foreach($this->getUser()->getClubs($offset+1) as $club) foreach($this->getUser()->getClubs((int) floor($offset/$count)+1) as $club)
$clbs[] = $club; $clbs[] = $club;
$clbsCount = $this->getUser()->getClubCount(); $clbsCount = $this->getUser()->getClubCount();
} else { } else {
@ -37,13 +37,7 @@ final class Groups extends VKAPIRequestHandler
for($i=0; $i < $ic; $i++) { for($i=0; $i < $ic; $i++) {
$usr = $clbs[$i]; $usr = $clbs[$i];
if(is_null($usr)) { if(is_null($usr)) {
$rClubs[$i] = (object)[
"id" => $clbs[$i],
"name" => "DELETED",
"deactivated" => "deleted"
];
} else if($clbs[$i] == NULL) {
} else { } else {
$rClubs[$i] = (object) [ $rClubs[$i] = (object) [
@ -151,6 +145,7 @@ final class Groups extends VKAPIRequestHandler
"screen_name" => $clb->getShortCode() ?? "club".$clb->getId(), "screen_name" => $clb->getShortCode() ?? "club".$clb->getId(),
"is_closed" => false, "is_closed" => false,
"type" => "group", "type" => "group",
"is_member" => !is_null($this->getUser()) ? (int) $clb->getSubscriptionStatus($this->getUser()) : 0,
"can_access_closed" => true, "can_access_closed" => true,
]; ];
@ -213,10 +208,6 @@ final class Groups extends VKAPIRequestHandler
else else
$response[$i]->can_post = $clb->canPost(); $response[$i]->can_post = $clb->canPost();
break; break;
case "is_member":
if(!is_null($this->getUser()))
$response[$i]->is_member = (int) $clb->getSubscriptionStatus($this->getUser());
break;
} }
} }
} }