From 213f1e286c6db65a46b1daeec2fc169b7033c3f1 Mon Sep 17 00:00:00 2001 From: lalka2016 <99399973+lalka2016@users.noreply.github.com> Date: Mon, 31 Jul 2023 10:00:55 +0300 Subject: [PATCH] Fix empty posts --- ServiceAPI/Wall.php | 9 ++++++--- VKAPI/Handlers/Wall.php | 3 ++- Web/Presenters/GroupPresenter.php | 9 +++++++-- Web/static/js/al_wall.js | 3 +-- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/ServiceAPI/Wall.php b/ServiceAPI/Wall.php index 73eeee36..62b1fe2c 100644 --- a/ServiceAPI/Wall.php +++ b/ServiceAPI/Wall.php @@ -110,7 +110,7 @@ class Wall implements Handler $reject(10, "Post is already declined"); if(!$post->canBePinnedBy($this->user)) - $reject(22, "Access to post denied :)"); + $reject(22, "Access to post denied"); $post->setSuggested(2); $post->save(); @@ -131,7 +131,7 @@ class Wall implements Handler $reject(10, "Post is declined"); if(!$post->canBePinnedBy($this->user)) - $reject(22, "Access to post denied :)"); + $reject(22, "Access to post denied"); $author = $post->getOwner(); $flags = 0; @@ -144,7 +144,10 @@ class Wall implements Handler $post->setSuggested(0); $post->setCreated(time()); $post->setFlags($flags); - $post->setContent($content); + + if(mb_strlen($content) > 0) { + $post->setContent($content); + } $post->save(); diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index dfe33c24..38033ea7 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -57,7 +57,8 @@ final class Wall extends VKAPIRequestHandler case "postponed": $this->fail(66666, "Otlojka is not implemented :)"); break; - # В апи, походу, нету метода, который бы публиковал запись из предложки + # В вкапи, походу, нету метода, который бы публиковал запись из предложки. + # Либо он закрыт для неофициальных клиентов, как gifts.send case "suggests": if($owner_id < 0) { if($wallOnwer->canBeModifiedBy($this->getUser())) { diff --git a/Web/Presenters/GroupPresenter.php b/Web/Presenters/GroupPresenter.php index 822582b7..3ead10b4 100644 --- a/Web/Presenters/GroupPresenter.php +++ b/Web/Presenters/GroupPresenter.php @@ -200,7 +200,7 @@ final class GroupPresenter extends OpenVKPresenter $this->willExecuteWriteAction(); $club = $this->clubs->get($id); - if(!$club || !$club->canBeModifiedBy($this->user->identity) || $club->isDeleted()) + if(!$club || !$club->canBeModifiedBy($this->user->identity)) $this->notFound(); else $this->template->club = $club; @@ -211,7 +211,12 @@ final class GroupPresenter extends OpenVKPresenter $club->setName(empty($this->postParam("name")) ? $club->getName() : $this->postParam("name")); $club->setAbout(empty($this->postParam("about")) ? NULL : $this->postParam("about")); - $club->setWall(empty($this->postParam("wall")) ? 0 : 1); + try { + $club->setWall(empty($this->postParam("wall")) ? 0 : (int)$this->postParam("wall")); + } catch(\Exception $e) { + $this->flashFail("err", "Fuck you", ""); + } + $club->setAdministrators_List_Display(empty($this->postParam("administrators_list_display")) ? 0 : $this->postParam("administrators_list_display")); $club->setEveryone_Can_Create_Topics(empty($this->postParam("everyone_can_create_topics")) ? 0 : 1); $club->setDisplay_Topics_Above_Wall(empty($this->postParam("display_topics_above_wall")) ? 0 : 1); diff --git a/Web/static/js/al_wall.js b/Web/static/js/al_wall.js index 9eff0e15..51683bd8 100644 --- a/Web/static/js/al_wall.js +++ b/Web/static/js/al_wall.js @@ -339,8 +339,7 @@ $(document).on("click", "#decline_post", async (e) => { } finally { u("#deleteMe").remove() } - - // а хули + NewNotification(tr("suggestion_succefully_declined"), "", null); e.currentTarget.parentNode.parentNode.parentNode.parentNode.parentNode.outerHTML = "" document.getElementById("cound").innerHTML = tr("x_suggested_posts_in_group", post)