VKAPI: Make getConversations output a real count of dialogs; Fix bug with extended param, when offset causes profile array to be dead xd

This commit is contained in:
veselcraft 2022-08-27 01:32:53 +03:00
parent 2fa36e123d
commit 4891030ed0
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E

View file

@ -152,6 +152,7 @@ final class Messages extends VKAPIRequestHandler
$this->requireUser();
$convos = (new MSGRepo)->getCorrespondencies($this->getUser(), -1, $count, $offset);
$convosCount = (new MSGRepo)->getCorrespondenciesCount($this->getUser());
$list = [];
$users = [];
@ -197,7 +198,6 @@ final class Messages extends VKAPIRequestHandler
$lastMessagePreview->emoji = true;
if($extended == 1) {
$users[] = $lastMessage->getSender()->getId();
$users[] = $author;
}
}
@ -210,16 +210,17 @@ final class Messages extends VKAPIRequestHandler
if($extended == 0){
return (object) [
"count" => sizeof($list),
"count" => $convosCount,
"items" => $list,
];
} else {
$users[] = $this->getUser()->getId();
$users = array_unique($users);
return (object) [
"count" => sizeof($list),
"count" => $convosCount,
"items" => $list,
"profiles" => (!empty($users) ? (new APIUsers)->get(implode(',', $users), $fields, $offset, $count) : [])
"profiles" => (!empty($users) ? (new APIUsers)->get(implode(',', $users), $fields, 0, $count+1) : [])
];
}
}