From 4891030ed062a61687d266d8274306116b46ac8d Mon Sep 17 00:00:00 2001 From: veselcraft Date: Sat, 27 Aug 2022 01:32:53 +0300 Subject: [PATCH] VKAPI: Make getConversations output a real count of dialogs; Fix bug with extended param, when offset causes profile array to be dead xd --- VKAPI/Handlers/Messages.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/VKAPI/Handlers/Messages.php b/VKAPI/Handlers/Messages.php index 85a38871..5767acc4 100644 --- a/VKAPI/Handlers/Messages.php +++ b/VKAPI/Handlers/Messages.php @@ -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 = []; @@ -195,9 +196,8 @@ final class Messages extends VKAPIRequestHandler $lastMessagePreview->body = $lastMessage->getText(false); $lastMessagePreview->text = $lastMessage->getText(false); $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) : []) ]; } }