From 9dbbc9e18eaa23cd1c4dced932deffe40863c68c Mon Sep 17 00:00:00 2001 From: Eliseu Amaro Date: Mon, 15 Nov 2021 17:38:15 +0000 Subject: [PATCH] [PLUGIN][Repeat] Fixed bug where checks dependant on user being logged in were attempted. --- plugins/Repeat/Repeat.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/plugins/Repeat/Repeat.php b/plugins/Repeat/Repeat.php index f34afcaa2e..880a53393e 100644 --- a/plugins/Repeat/Repeat.php +++ b/plugins/Repeat/Repeat.php @@ -31,6 +31,7 @@ use App\Entity\Note; use App\Util\Common; use App\Util\Exception\DuplicateFoundException; use App\Util\Exception\InvalidFormException; +use App\Util\Exception\NoLoggedInUser; use App\Util\Exception\NoSuchNoteException; use App\Util\Exception\NotFoundException; use App\Util\Exception\RedirectException; @@ -92,10 +93,19 @@ class Repeat extends NoteHandlerPlugin return Event::next; } + /** + * @throws \App\Util\Exception\NoLoggedInUser + */ public function onAppendCardNote(array $vars, array &$result) { // if note is the original and user isn't the one who repeated, append on end "user repeated this" // if user is the one who repeated, append on end "you repeated this, remove repeat?" - $current_actor_id = (Common::actor())->getId(); + $check_user = true; + try { + $user = Common::ensureLoggedIn(); + } catch (NoLoggedInUser $e) { + $check_user = false; + } + $note = $vars['note']; $complementary_info = ''; @@ -118,7 +128,7 @@ class Repeat extends NoteHandlerPlugin $repeat_actor_url = $actor->getUrl(); $repeat_actor_nickname = $actor->getNickname(); - if ($actor->getId() === $current_actor_id) { + if ($check_user && $actor->getId() === (Common::actor())->getId()) { // If the repeat is yours $prepend = "You, " . ($prepend = &$complementary_info); $complementary_info = $prepend;