diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index db4f340..a1ea018 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -460,6 +460,87 @@ class TorrentController extends AbstractController ]); } + #[Route( + '/{_locale}/rss/torrents', + name: 'rss_torrents_recent', + defaults: [ + '_locale' => '%app.locale%' + ], + requirements: [ + '_locale' => '%app.locales%' + ], + methods: + [ + 'GET' + ] + )] + public function rssRecent( + Request $request, + UserService $userService, + TorrentService $torrentService, + ActivityService $activityService + ): Response + { + // Init user + $user = $this->initUser( + $request, + $userService, + $activityService + ); + + // Get total torrents + $total = $torrentService->findTorrentsTotal( + [], + $user->getLocales(), + !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all + !$user->isModerator() ? true : null // show approved content only for regular users + ); + + // Create torrents list + $torrents = []; + foreach ($torrentService->findTorrents( + [], + $user->getLocales(), + !$user->isModerator() && $user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all + !$user->isModerator() ? true : null, // show approved content only for regular users + $this->getParameter('app.pagination'), + 0 + ) as $torrent) + { + // Read file + if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId())) + { + throw $this->createNotFoundException(); // @TODO exception + } + + $torrents[] = + [ + 'id' => $torrent->getId(), + 'added' => $torrent->getAdded(), + 'file' => + [ + 'name' => $file->getName(), + ], + 'user' => + [ + 'id' => $torrent->getUserId(), + ], + ]; + } + + $response = new Response(); + $response->headers->set('Content-Type', 'text/xml'); + + return $this->render( + 'default/torrent/list.rss.twig', + [ + 'query' => $request->query->get('query'), + 'torrents' => $torrents + ], + $response + ); + } + // Forms #[Route( '/{_locale}/submit', diff --git a/templates/default/activity/event/undefined.rss.twig b/templates/default/activity/event/undefined.rss.twig index 09bcc56..34ab004 100644 --- a/templates/default/activity/event/undefined.rss.twig +++ b/templates/default/activity/event/undefined.rss.twig @@ -2,6 +2,6 @@ {{ 'undefined event' | trans }} {{ 'by' | trans }} #{{ user.id }} #{{ user.id }} {{ added | date('D, d M Y h:i:s O') }} - {{ path('user_info', { userId : user.id }) }}#activity-{{ id }} - {{ path('user_info', { userId : user.id }) }}#activity + {{ url('user_info', { userId : user.id }) }}#activity-{{ id }} + {{ url('user_info', { userId : user.id }) }}#activity \ No newline at end of file diff --git a/templates/default/activity/list.rss.twig b/templates/default/activity/list.rss.twig index c7462db..2fabaaa 100644 --- a/templates/default/activity/list.rss.twig +++ b/templates/default/activity/list.rss.twig @@ -2,7 +2,7 @@ - {{ name }} + {{ name }} - {{ 'Activity' | trans }} {{ url('torrent_recent') }} {% for activity in activities %} {{ render(controller( diff --git a/templates/default/torrent/list.html.twig b/templates/default/torrent/list.html.twig index 26056e5..c74e816 100644 --- a/templates/default/torrent/list.html.twig +++ b/templates/default/torrent/list.html.twig @@ -4,7 +4,7 @@