diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index ec153695..5b0035de 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -22,6 +22,32 @@ final class Wall extends VKAPIRequestHandler foreach ($posts->getPostsFromUsersWall((int)$owner_id, 1, $count, $offset) as $post) { $from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId(); + + $attachments; + foreach($post->getChildren() as $attachment) + { + if($attachment instanceof \openvk\Web\Models\Entities\Photo) + { + $attachments[] = [ + "type" => "photo", + "photo" => [ + "album_id" => $attachment->getAlbum()->getId(), + "date" => $attachment->getPublicationTime()->timestamp(), + "id" => $attachment->getVirtualId(), + "owner_id" => $attachment->getOwner()->getId(), + "sizes" => array([ + "height" => $attachment->getDimentions()[1], + "url" => $attachment->getURL(), + "type" => "m", + "width" => $attachment->getDimentions()[0], + ]), + "text" => "", + "has_tags" => false + ] + ]; + } + } + $items[] = (object)[ "id" => $post->getVirtualId(), "from_id" => $from_id, @@ -35,6 +61,7 @@ final class Wall extends VKAPIRequestHandler "can_archive" => false, // TODO MAYBE "is_archived" => false, "is_pinned" => $post->isPinned(), + "attachments" => $attachments, "post_source" => (object)["type" => "vk"], "comments" => (object)[ "count" => $post->getCommentsCount(), @@ -127,6 +154,31 @@ final class Wall extends VKAPIRequestHandler $post = (new PostsRepo)->getPostById(intval($id[0]), intval($id[1])); if($post) { $from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId(); + $attachments; + foreach($post->getChildren() as $attachment) + { + if($attachment instanceof \openvk\Web\Models\Entities\Photo) + { + $attachments[] = [ + "type" => "photo", + "photo" => [ + "album_id" => $attachment->getAlbum()->getId(), + "date" => $attachment->getPublicationTime()->timestamp(), + "id" => $attachment->getVirtualId(), + "owner_id" => $attachment->getOwner()->getId(), + "sizes" => array([ + "height" => $attachment->getDimentions()[1], + "url" => $attachment->getURL(), + "type" => "m", + "width" => $attachment->getDimentions()[0], + ]), + "text" => "", + "has_tags" => false + ] + ]; + } + } + $items[] = (object)[ "id" => $post->getVirtualId(), "from_id" => $from_id, @@ -141,6 +193,7 @@ final class Wall extends VKAPIRequestHandler "is_archived" => false, "is_pinned" => $post->isPinned(), "post_source" => (object)["type" => "vk"], + "attachments" => $attachments, "comments" => (object)[ "count" => $post->getCommentsCount(), "can_post" => 1 diff --git a/Web/Models/Entities/Photo.php b/Web/Models/Entities/Photo.php index ecda93f6..0c0e8941 100644 --- a/Web/Models/Entities/Photo.php +++ b/Web/Models/Entities/Photo.php @@ -1,5 +1,7 @@ getRecord()->hash; + + return getimagesize($this->pathFromHash($hash)); + } + + function getAlbum(): ?Album + { + return (new Albums)->getAlbumByPhotoId($this); + } } diff --git a/Web/Models/Repositories/Albums.php b/Web/Models/Repositories/Albums.php index e1bcc671..0da26ff0 100644 --- a/Web/Models/Repositories/Albums.php +++ b/Web/Models/Repositories/Albums.php @@ -1,6 +1,7 @@ getContext()->table("album_relations")->where(["media" => $photo->getId()])->fetch(); + + return $this->get($dbalbum->collection); + } }