diff --git a/plugins/Favourite/Controller/Favourite.php b/plugins/Favourite/Controller/Favourite.php new file mode 100644 index 0000000000..f0b5d273ac --- /dev/null +++ b/plugins/Favourite/Controller/Favourite.php @@ -0,0 +1,70 @@ +. + +// }}} + +namespace Plugin\Favourite\Controller; + +use App\Core\DB\DB; +use Symfony\Component\HttpFoundation\Request; + +class Favourite +{ + public function favourites(Request $request) + { + $actor_id = Common::ensureLoggedIn()->getId(); + $notes = DB::dql('select f from App\Entity\Favourite f ' . + 'where f.gsactor_id = :id ' . + 'order by f.created DESC', ['id' => $actor_id]); + + Event::handle('FormatNoteList', [&$notes]); + + return [ + '_template' => 'network/public.html.twig', + 'notes' => $notes, + ]; + } + + /** + * Reverse favourites stream + * + * @param Request $request + * + * @throws \App\Util\Exception\NoLoggedInUser user not logged in + * + * @return array template + */ + public function reverseFavourites(Request $request) + { + $actor_id = Common::ensureLoggedIn()->getId(); + $notes = DB::dql('select n from App\Entity\Note n, App\Entity\Favourite f ' . + 'where n.id = f.note_id ' . + 'and f.gsactor_id != :id ' . + 'and n.gsactor_id = :id ' . + 'order by f.created DESC' , + ['id' => $actor_id]); + + Event::handle('FormatNoteList', [&$notes]); + + return [ + '_template' => 'network/reversefavs.html.twig', + 'notes' => $notes, + ]; + } +} diff --git a/plugins/Favourite/Favourite.php b/plugins/Favourite/Favourite.php index 4837371786..514e7ba88d 100644 --- a/plugins/Favourite/Favourite.php +++ b/plugins/Favourite/Favourite.php @@ -70,4 +70,11 @@ class Favourite extends Module $actions[] = $form->createView(); return Event::next; } + + public function onAddRoute(RouteLoader $r) + { + $r->connect('actors', '/actors', [Controller\Directory::class, 'actors']); + $r->connect('groups', '/groups', [Controller\Directory::class, 'groups']); + return Event::next; + } }