From 174ed53d925f4f4dfffe4a01b3656d10977149e6 Mon Sep 17 00:00:00 2001 From: veselcraft Date: Mon, 25 Jul 2022 13:25:06 +0300 Subject: [PATCH] VKAPI: Add support to start_from parameter --- VKAPI/Handlers/Newsfeed.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/VKAPI/Handlers/Newsfeed.php b/VKAPI/Handlers/Newsfeed.php index 71379256..19cbfa48 100644 --- a/VKAPI/Handlers/Newsfeed.php +++ b/VKAPI/Handlers/Newsfeed.php @@ -10,9 +10,6 @@ final class Newsfeed extends VKAPIRequestHandler { $this->requireUser(); - if($offset != 0) - $start_from = $offset; - $id = $this->getUser()->getId(); $subs = DatabaseConnection::i() ->getContext() @@ -29,12 +26,15 @@ final class Newsfeed extends VKAPIRequestHandler ->select("id") ->where("wall IN (?)", $ids) ->where("deleted", 0) + ->where("created < (?)", empty($start_from) ? time()+1 : $start_from) ->order("created DESC"); $rposts = []; foreach($posts->page((int) ($offset + 1), $count) as $post) $rposts[] = (new PostsRepo)->get($post->id)->getPrettyId(); - return (new Wall)->getById(implode(',', $rposts), $extended, $fields, $this->getUser()); + $response = (new Wall)->getById(implode(',', $rposts), $extended, $fields, $this->getUser()); + $response->next_from = end($response->items)->date; + return $response; } }