diff --git a/Web/Models/Entities/Postable.php b/Web/Models/Entities/Postable.php
index 23981cc1..bc59e7b1 100644
--- a/Web/Models/Entities/Postable.php
+++ b/Web/Models/Entities/Postable.php
@@ -1,5 +1,6 @@
get($like->origin);
}
+
+ function getReposters(): \Traversable
+ {
+ $sel = $this->getRecord()
+ ->related("attachments.attachable_id")
+ ->where([
+ "attachable_type" => get_class($this),
+ "attachable_id" => $this->getId(),
+ "target_type" => get_class(new Post),
+ ]);
+
+ foreach ($sel as $repost) {
+ $post = (new Posts)->get($repost->target_id);
+ if ($post && !$post->isDeleted()) {
+ yield $post->getOwner();
+ }
+ }
+ }
function isAnonymous(): bool
{
diff --git a/Web/Presenters/WallPresenter.php b/Web/Presenters/WallPresenter.php
index 3e115ec7..c900f480 100644
--- a/Web/Presenters/WallPresenter.php
+++ b/Web/Presenters/WallPresenter.php
@@ -3,7 +3,7 @@ namespace openvk\Web\Presenters;
use openvk\Web\Models\Exceptions\TooMuchOptionsException;
use openvk\Web\Models\Entities\{Poll, Post, Photo, Video, Club, User};
use openvk\Web\Models\Entities\Notifications\{MentionNotification, RepostNotification, WallPostNotification};
-use openvk\Web\Models\Repositories\{Posts, Users, Clubs, Albums, Notes};
+use openvk\Web\Models\Repositories\{Comments, Posts, Users, Clubs, Albums, Notes};
use Chandler\Database\DatabaseConnection;
use Nette\InvalidStateException as ISE;
use Bhaktaraz\RSSGenerator\Item;
@@ -498,4 +498,64 @@ final class WallPresenter extends OpenVKPresenter
# TODO localize message based on language and ?act=(un)pin
$this->flashFail("succ", tr("information_-1"), tr("changes_saved_comment"));
}
+
+ private function fetchLikers($object): array
+ {
+ if (!$object || $object->isDeleted())
+ return ["success" => false, "error" => "Объект не найден"];
+
+ $response = [];
+ foreach ($object->getLikers() as $liker) {
+ $liker = [
+ "url" => $liker->getURL(),
+ "fname" => $liker->getFirstName(),
+ "lname" => $liker->getLastName(),
+ "avatar" => $liker->getAvatarURL()
+ ];
+
+ if (!in_array($liker, $response)) {
+ $response[] = $liker;
+ }
+ }
+
+ return ["success" => true, "payload" => [count($response), $response]];
+ }
+
+ function renderLikers(int $wall, int $post_id): void
+ {
+ $this->returnJson($this->fetchLikers($this->posts->getPostById($wall, $post_id)));
+ }
+
+ function renderReposters(int $wall, int $post_id): void
+ {
+ $post = $this->posts->getPostById($wall, $post_id);
+ if (!$post || $post->isDeleted()) {
+ $this->returnJson(["success" => false, "error" => "Запись не найдена"]);
+ }
+
+ $response = [];
+ foreach ($post->getReposters() as $reposter) {
+ $_reposter = $reposter instanceof User ? [
+ "fname" => $reposter->getFirstName(),
+ "lname" => $reposter->getLastName()
+ ] : [
+ "fname" => $reposter->getCanonicalName(),
+ "lname" => ""
+ ];
+
+ $_reposter["url"] = $reposter->getURL();
+ $_reposter["avatar"] = $reposter->getAvatarURL();
+
+ if (!in_array($_reposter, $response)) {
+ $response[] = $_reposter;
+ }
+ }
+
+ $this->returnJson(["success" => true, "payload" => [count($response), $response]]);
+ }
+
+ function renderCommentLikers(int $comment_id): void
+ {
+ $this->returnJson($this->fetchLikers((new Comments)->get($comment_id)));
+ }
}
diff --git a/Web/Presenters/templates/Photos/Photo.xml b/Web/Presenters/templates/Photos/Photo.xml
index 047f382a..666f1ecb 100644
--- a/Web/Presenters/templates/Photos/Photo.xml
+++ b/Web/Presenters/templates/Photos/Photo.xml
@@ -49,7 +49,6 @@
{_edit}
{_delete}
- {_"open_original"}
{_report}