From 964dae97aae9d75ee502abc0d5e90099e21d9b37 Mon Sep 17 00:00:00 2001 From: ghost Date: Wed, 11 Oct 2023 01:34:04 +0300 Subject: [PATCH] define torrent add event #4 --- src/Controller/TorrentController.php | 9 +++++++- src/Service/ActivityService.php | 31 +++++++++++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index a8e01be..d242241 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -179,7 +179,8 @@ class TorrentController extends AbstractController Request $request, TranslatorInterface $translator, UserService $userService, - TorrentService $torrentService + TorrentService $torrentService, + ActivityService $activityService ): Response { // Init user @@ -289,6 +290,12 @@ class TorrentController extends AbstractController $user->isApproved() ); + $activityService->addEventTorrentAdd( + $user->getId(), + time(), + $torrent->getId() + ); + // Redirect to info article created return $this->redirectToRoute( 'torrent_info', diff --git a/src/Service/ActivityService.php b/src/Service/ActivityService.php index 9db22e3..8b57eb6 100644 --- a/src/Service/ActivityService.php +++ b/src/Service/ActivityService.php @@ -30,7 +30,7 @@ class ActivityService } // User - public function addEventUserJoin( + public function addEventUserAdd( int $userId, int $added ): ?Activity @@ -121,6 +121,35 @@ class ActivityService } // Torrent + public function addEventTorrentAdd( + int $userId, + int $added, + int $torrentId + ): ?Activity + { + $activity = new Activity(); + + $activity->setEvent( + Activity::EVENT_TORRENT_ADD + ); + + $activity->setUserId( + $userId + ); + + $activity->setAdded( + $added + ); + + $activity->setTorrentId( + $torrentId + ); + + $this->entityManagerInterface->persist($activity); + $this->entityManagerInterface->flush(); + + return $activity; + } /// Torrent star public function addEventTorrentStarAdd(