From 49d8bc39a12afcd48292266036176884bd8a0c99 Mon Sep 17 00:00:00 2001 From: mrilyew <99399973+mrilyew@users.noreply.github.com> Date: Sun, 10 Nov 2024 22:15:44 +0300 Subject: [PATCH] =?UTF-8?q?fix=20possible=20bugs=20(13=20=D1=81=D0=B5?= =?UTF-8?q?=D1=80=D0=B8=D1=8F)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- VKAPI/Handlers/Wall.php | 16 ++++++++-------- Web/Presenters/InternalAPIPresenter.php | 2 ++ Web/Presenters/templates/Group/View.xml | 4 ++-- Web/Presenters/templates/User/View.xml | 4 ++-- Web/Presenters/templates/Videos/View.xml | 1 + .../templates/components/post/microblogpost.xml | 2 +- .../templates/components/post/oldpost.xml | 2 +- Web/static/css/bsdn.css | 1 + Web/static/css/main.css | 4 ++-- Web/static/js/al_wall.js | 8 ++++++-- Web/static/js/messagebox.js | 2 +- bootstrap.php | 1 + 12 files changed, 28 insertions(+), 19 deletions(-) diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 4b711827..dad7f883 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -284,12 +284,16 @@ final class Wall extends VKAPIRequestHandler foreach($psts as $pst) { $id = explode("_", $pst); - $post = (new PostsRepo)->getPostById(intval($id[0]), intval($id[1])); + $post = (new PostsRepo)->getPostById(intval($id[0]), intval($id[1]), true); if($post && !$post->isDeleted()) { if(!$post->canBeViewedBy($this->getUser())) continue; + if($post->getSuggestionType() != 0 && !$post->canBeEditedBy($this->getUser())) { + continue; + } + $from_id = get_class($post->getOwner()) == "openvk\Web\Models\Entities\Club" ? $post->getOwner()->getId() * (-1) : $post->getOwner()->getId(); $attachments = []; $repost = []; // чел высрал семь сигарет 😳 помянем 🕯 @@ -594,10 +598,6 @@ final class Wall extends VKAPIRequestHandler if($wall > 0 && $wall !== $this->user->identity->getId()) (new WallPostNotification($wallOwner, $post, $this->user->identity))->emit(); - if($should_be_suggested) { - return (object)["post_id" => "on_view"]; - } - return (object)["post_id" => $post->getVirtualId()]; } @@ -728,7 +728,7 @@ final class Wall extends VKAPIRequestHandler "date" => $comment->getPublicationTime()->timestamp(), "text" => $comment->getText(false), "post_id" => $post->getVirtualId(), - "owner_id" => $post->isPostedOnBehalfOfGroup() ? $post->getOwner()->getId() * -1 : $post->getOwner()->getId(), + "owner_id" => method_exists($post, 'isPostedOnBehalfOfGroup') && $post->isPostedOnBehalfOfGroup() ? $post->getOwner()->getId() * -1 : $post->getOwner()->getId(), "parents_stack" => [], "attachments" => $attachments, "thread" => [ @@ -815,7 +815,7 @@ final class Wall extends VKAPIRequestHandler "date" => $comment->getPublicationTime()->timestamp(), "text" => $comment->getText(false), "post_id" => $comment->getTarget()->getVirtualId(), - "owner_id" => $comment->getTarget()->isPostedOnBehalfOfGroup() ? $comment->getTarget()->getOwner()->getId() * -1 : $comment->getTarget()->getOwner()->getId(), + "owner_id" => method_exists($comment->getTarget(), 'isPostedOnBehalfOfGroup') && $comment->getTarget()->isPostedOnBehalfOfGroup() ? $comment->getTarget()->getOwner()->getId() * -1 : $comment->getTarget()->getOwner()->getId(), "parents_stack" => [], "attachments" => $attachments, "likes" => [ @@ -966,7 +966,7 @@ final class Wall extends VKAPIRequestHandler $this->fail(-66, "Post will be empty, don't saving."); } - $post = (new PostsRepo)->getPostById($owner_id, $post_id); + $post = (new PostsRepo)->getPostById($owner_id, $post_id, true); if(!$post || $post->isDeleted()) $this->fail(102, "Invalid post"); diff --git a/Web/Presenters/InternalAPIPresenter.php b/Web/Presenters/InternalAPIPresenter.php index efca2807..e8830497 100644 --- a/Web/Presenters/InternalAPIPresenter.php +++ b/Web/Presenters/InternalAPIPresenter.php @@ -151,6 +151,8 @@ final class InternalAPIPresenter extends OpenVKPresenter exit(''); } + header("Content-Type: text/plain"); + if($type == 'post') { $this->template->_template = 'components/post.xml'; $this->template->post = $post; diff --git a/Web/Presenters/templates/Group/View.xml b/Web/Presenters/templates/Group/View.xml index 79ef3704..f42dab17 100644 --- a/Web/Presenters/templates/Group/View.xml +++ b/Web/Presenters/templates/Group/View.xml @@ -168,10 +168,10 @@ {/if} {var $canReport = $thisUser->getId() != $club->getOwner()->getId()} {if $canReport} - {_report} + {_report}