[PLUGIN][Favourite] Fix routes

This commit is contained in:
Diogo Peralta Cordeiro 2022-01-04 22:36:16 +00:00
parent cd6ce3542e
commit 3f8fab0021
Signed by: diogo
GPG Key ID: 18D2D35001FBFAB0
2 changed files with 10 additions and 10 deletions

View File

@ -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( $notes = DB::dql(
<<< 'EOF' <<< 'EOF'
select n from note n 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 where f.actor_id = :id
order by f.created DESC order by f.created DESC
EOF, 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]); $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 * @return array template
*/ */
public function reverseFavouritesByActorId(Request $request, int $id): array public function reverseFavouritesViewByActorId(Request $request, int $id): array
{ {
$notes = DB::dql( $notes = DB::dql(
<<< 'EOF' <<< 'EOF'
select n from note n 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 where f.actor_id != :id
and n.actor_id = :id and n.actor_id = :id
order by f.created DESC 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]); $user = DB::findOneBy('local_user', ['nickname' => $nickname]);
return self::reverseFavouritesByActorId($request, $user->getId()); return self::reverseFavouritesViewByActorId($request, $user->getId());
} }
} }

View File

@ -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']); $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 // 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_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, 'reverseFavouritesByActorNickname']); $r->connect(id: 'favourites_reverse_view_by_nickname', uri_path: '/@{nickname<' . Nickname::DISPLAY_FMT . '>}/reverse_favourites', target: [Controller\Favourite::class, 'reverseFavouritesViewByActorNickname']);
return Event::next; return Event::next;
} }