add torrent star event support #4

This commit is contained in:
ghost 2023-10-11 01:09:34 +03:00
parent ef84fefca3
commit a3dd5a81a9
7 changed files with 174 additions and 6 deletions

View file

@ -1005,7 +1005,8 @@ class TorrentController extends AbstractController
Request $request,
TranslatorInterface $translator,
UserService $userService,
TorrentService $torrentService
TorrentService $torrentService,
ActivityService $activityService
): Response
{
// Init user
@ -1028,12 +1029,31 @@ class TorrentController extends AbstractController
}
// Update
$torrentService->toggleTorrentStar(
$value = $torrentService->toggleTorrentStar(
$torrent->getId(),
$user->getId(),
time()
);
// Register activity event
if ($value)
{
$activityService->addEventTorrentStarAdd(
$user->getId(),
time(),
$torrent->getId()
);
}
else
{
$activityService->addEventTorrentStarDelete(
$user->getId(),
time(),
$torrent->getId()
);
}
// Redirect to info article created
return $this->redirectToRoute(
'torrent_info',