gbyhkukyhrhrthy

This commit is contained in:
lalka2016 2023-06-22 13:08:49 +03:00
parent fa2698cda1
commit 07f047a314
2 changed files with 18 additions and 4 deletions

View file

@ -346,7 +346,7 @@ final class Board extends VKAPIRequestHandler
$topicy = (new TopicsRepo)->getTopicById((int)$id[0], (int)$id[1]); $topicy = (new TopicsRepo)->getTopicById((int)$id[0], (int)$id[1]);
if($topicy && !$topicy->isDeleted()) { 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);
} }
} }
} }

View file

@ -71,7 +71,7 @@ class Topic extends Postable
function getFirstComment(): ?Comment function getFirstComment(): ?Comment
{ {
$array = iterator_to_array($this->getComments(1)); $array = iterator_to_array($this->getComments(1));
return isset($array[0]) ? $array[0] : NULL; return $array[0] ?? NULL;
} }
function getUpdateTime(): DateTime function getUpdateTime(): DateTime
@ -97,9 +97,23 @@ class Topic extends Postable
$res->id = $this->getId(); $res->id = $this->getId();
$res->title = $this->getTitle(); $res->title = $this->getTitle();
$res->created = $this->getPublicationTime()->timestamp(); $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 = $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_closed = (int)$this->isClosed();
$res->is_fixed = (int)$this->isPinned(); $res->is_fixed = (int)$this->isPinned();
$res->comments = $this->getCommentsCount(); $res->comments = $this->getCommentsCount();