From 3f8fab0021dff23a637597d780d31ea23ae12928 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Tue, 4 Jan 2022 22:36:16 +0000 Subject: [PATCH] [PLUGIN][Favourite] Fix routes --- plugins/Favourite/Controller/Favourite.php | 16 ++++++++-------- plugins/Favourite/Favourite.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/plugins/Favourite/Controller/Favourite.php b/plugins/Favourite/Controller/Favourite.php index 50e796c18e..c5e534145f 100644 --- a/plugins/Favourite/Controller/Favourite.php +++ b/plugins/Favourite/Controller/Favourite.php @@ -161,12 +161,12 @@ class Favourite extends FeedController ]; } - public function favouritesByActorId(Request $request, int $id) + public function favouritesViewByActorId(Request $request, int $id) { $notes = DB::dql( <<< 'EOF' select n from note n - join favourite f with n.id = f.note_id + join note_favourite f with n.id = f.note_id where f.actor_id = :id order by f.created DESC EOF, @@ -180,10 +180,10 @@ class Favourite extends FeedController ]; } - public function favouritesByActorNickname(Request $request, string $nickname) + public function favouritesViewByActorNickname(Request $request, string $nickname) { $user = DB::findOneBy('local_user', ['nickname' => $nickname]); - return self::favouritesByActorId($request, $user->getId()); + return self::favouritesViewByActorId($request, $user->getId()); } /** @@ -193,12 +193,12 @@ class Favourite extends FeedController * * @return array template */ - public function reverseFavouritesByActorId(Request $request, int $id): array + public function reverseFavouritesViewByActorId(Request $request, int $id): array { $notes = DB::dql( <<< 'EOF' select n from note n - join favourite f with n.id = f.note_id + join note_favourite f with n.id = f.note_id where f.actor_id != :id and n.actor_id = :id order by f.created DESC @@ -213,9 +213,9 @@ class Favourite extends FeedController ]; } - public function reverseFavouritesByActorNickname(Request $request, string $nickname) + public function reverseFavouritesViewByActorNickname(Request $request, string $nickname) { $user = DB::findOneBy('local_user', ['nickname' => $nickname]); - return self::reverseFavouritesByActorId($request, $user->getId()); + return self::reverseFavouritesViewByActorId($request, $user->getId()); } } diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index d3df29c6c9..6da9e5b6d7 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -195,8 +195,8 @@ class Favourite extends NoteHandlerPlugin $r->connect(id: 'favourites_reverse_view_by_actor_id', uri_path: '/actor/{id<\d+>}/reverse_favourites', target: [Controller\Favourite::class, 'favouritesReverseViewByActorId']); // View all favourites by nickname - $r->connect(id: 'favourites_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/favourites', target: [Controller\Favourite::class, 'favouritesByActorNickname']); - $r->connect(id: 'favourites_reverse_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/reverse_favourites', target: [Controller\Favourite::class, 'reverseFavouritesByActorNickname']); + $r->connect(id: 'favourites_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/favourites', target: [Controller\Favourite::class, 'favouritesViewByActorNickname']); + $r->connect(id: 'favourites_reverse_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/reverse_favourites', target: [Controller\Favourite::class, 'reverseFavouritesViewByActorNickname']); return Event::next; }