From 07f047a314e04f3187892e14e3dda19e3324d7fc Mon Sep 17 00:00:00 2001 From: lalka2016 <99399973+lalka2016@users.noreply.github.com> Date: Thu, 22 Jun 2023 13:08:49 +0300 Subject: [PATCH] gbyhkukyhrhrthy --- VKAPI/Handlers/Board.php | 2 +- Web/Models/Entities/Topic.php | 20 +++++++++++++++++--- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/VKAPI/Handlers/Board.php b/VKAPI/Handlers/Board.php index 3efab33e..5a4b87ef 100644 --- a/VKAPI/Handlers/Board.php +++ b/VKAPI/Handlers/Board.php @@ -346,7 +346,7 @@ final class Board extends VKAPIRequestHandler $topicy = (new TopicsRepo)->getTopicById((int)$id[0], (int)$id[1]); if($topicy && !$topicy->isDeleted()) { - $arr["items"] = $topicy->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90); + $arr["items"][] = $topicy->toVkApiStruct($preview, $preview_length > 1 ? $preview_length : 90); } } } diff --git a/Web/Models/Entities/Topic.php b/Web/Models/Entities/Topic.php index dfff487b..d4257816 100644 --- a/Web/Models/Entities/Topic.php +++ b/Web/Models/Entities/Topic.php @@ -71,7 +71,7 @@ class Topic extends Postable function getFirstComment(): ?Comment { $array = iterator_to_array($this->getComments(1)); - return isset($array[0]) ? $array[0] : NULL; + return $array[0] ?? NULL; } function getUpdateTime(): DateTime @@ -97,9 +97,23 @@ class Topic extends Postable $res->id = $this->getId(); $res->title = $this->getTitle(); $res->created = $this->getPublicationTime()->timestamp(); - $res->created_by = $this->getOwner() instanceof User ? $this->getOwner()->getId() : $this->getOwner()->getId() * -1; + + if($this->getOwner() instanceof User) { + $res->created_by = $this->getOwner()->getId(); + } else { + $res->created_by = $this->getOwner()->getId() * -1; + } + $res->updated = $this->getUpdateTime()->timestamp(); - $res->updated_by = $this->getLastComment() ? $this->getLastComment()->getOwner() instanceof User ? $this->getLastComment()->getOwner()->getId() : $this->getLastComment()->getOwner()->getId() * -1 : NULL; + + if($this->getLastComment()) { + if($this->getLastComment()->getOwner() instanceof User) { + $res->updated_by = $this->getLastComment()->getOwner()->getId(); + } else { + $res->updated_by = $this->getLastComment()->getOwner()->getId() * -1; + } + } + $res->is_closed = (int)$this->isClosed(); $res->is_fixed = (int)$this->isPinned(); $res->comments = $this->getCommentsCount();