diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php
index 0017c5f..2b0363a 100644
--- a/src/Controller/ActivityController.php
+++ b/src/Controller/ActivityController.php
@@ -330,6 +330,61 @@ class ActivityController extends AbstractController
break;
+ // Torrent Download
+ case $activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD:
+
+ return $this->render(
+ 'default/activity/event/torrent/download/file/add.html.twig',
+ [
+ 'added' => $activity->getAdded(),
+ 'user' =>
+ [
+ 'id' => $activity->getUserId(),
+ 'identicon' => $userService->identicon(
+ $userService->getUser(
+ $activity->getUserId()
+ )->getAddress()
+ )
+ ],
+ 'torrent' =>
+ [
+ 'id' => $activity->getTorrentId(),
+ 'name' => $torrentService->readTorrentFileByTorrentId(
+ $activity->getTorrentId()
+ )->getName()
+ ]
+ ]
+ );
+
+ break;
+
+ case $activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD:
+
+ return $this->render(
+ 'default/activity/event/torrent/download/magnet/add.html.twig',
+ [
+ 'added' => $activity->getAdded(),
+ 'user' =>
+ [
+ 'id' => $activity->getUserId(),
+ 'identicon' => $userService->identicon(
+ $userService->getUser(
+ $activity->getUserId()
+ )->getAddress()
+ )
+ ],
+ 'torrent' =>
+ [
+ 'id' => $activity->getTorrentId(),
+ 'name' => $torrentService->readTorrentFileByTorrentId(
+ $activity->getTorrentId()
+ )->getName()
+ ]
+ ]
+ );
+
+ break;
+
/// Torrent Locales
case $activity::EVENT_TORRENT_LOCALES_ADD:
diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php
index d242241..8b262bc 100644
--- a/src/Controller/TorrentController.php
+++ b/src/Controller/TorrentController.php
@@ -1088,7 +1088,8 @@ class TorrentController extends AbstractController
Request $request,
TranslatorInterface $translator,
UserService $userService,
- TorrentService $torrentService
+ TorrentService $torrentService,
+ ActivityService $activityService
): Response
{
// Init user
@@ -1119,12 +1120,19 @@ class TorrentController extends AbstractController
}
// Register download
- $torrentService->registerTorrentDownloadFile(
+ $torrentService->addTorrentDownloadFile(
$torrent->getId(),
$user->getId(),
time()
);
+ // Register download event
+ $activityService->addEventTorrentDownloadFileAdd(
+ $user->getId(),
+ time(),
+ $torrent->getId()
+ );
+
// Filter trackers
$file->setAnnounceList(
[
@@ -1183,7 +1191,8 @@ class TorrentController extends AbstractController
Request $request,
TranslatorInterface $translator,
UserService $userService,
- TorrentService $torrentService
+ TorrentService $torrentService,
+ ActivityService $activityService
): Response
{
// Init user
@@ -1214,12 +1223,19 @@ class TorrentController extends AbstractController
}
// Register download
- $torrentService->registerTorrentDownloadMagnet(
+ $torrentService->addTorrentDownloadMagnet(
$torrent->getId(),
$user->getId(),
time()
);
+ // Register download event
+ $activityService->addEventTorrentDownloadMagnetAdd(
+ $user->getId(),
+ time(),
+ $torrent->getId()
+ );
+
// Filter trackers
$file->setAnnounceList(
[
diff --git a/src/Service/ActivityService.php b/src/Service/ActivityService.php
index 8b57eb6..c81925c 100644
--- a/src/Service/ActivityService.php
+++ b/src/Service/ActivityService.php
@@ -151,6 +151,67 @@ class ActivityService
return $activity;
}
+ /// Torrent Download
+ public function addEventTorrentDownloadFileAdd(
+ int $userId,
+ int $added,
+ int $torrentId
+ ): ?Activity
+ {
+ $activity = new Activity();
+
+ $activity->setEvent(
+ Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD
+ );
+
+ $activity->setUserId(
+ $userId
+ );
+
+ $activity->setAdded(
+ $added
+ );
+
+ $activity->setTorrentId(
+ $torrentId
+ );
+
+ $this->entityManagerInterface->persist($activity);
+ $this->entityManagerInterface->flush();
+
+ return $activity;
+ }
+
+ public function addEventTorrentDownloadMagnetAdd(
+ int $userId,
+ int $added,
+ int $torrentId
+ ): ?Activity
+ {
+ $activity = new Activity();
+
+ $activity->setEvent(
+ Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD
+ );
+
+ $activity->setUserId(
+ $userId
+ );
+
+ $activity->setAdded(
+ $added
+ );
+
+ $activity->setTorrentId(
+ $torrentId
+ );
+
+ $this->entityManagerInterface->persist($activity);
+ $this->entityManagerInterface->flush();
+
+ return $activity;
+ }
+
/// Torrent star
public function addEventTorrentStarAdd(
int $userId,
diff --git a/src/Service/TorrentService.php b/src/Service/TorrentService.php
index 7275f1d..c792793 100644
--- a/src/Service/TorrentService.php
+++ b/src/Service/TorrentService.php
@@ -630,7 +630,7 @@ class TorrentService
->findTorrentDownloadFilesTotalByTorrentId($torrentId);
}
- public function registerTorrentDownloadFile(
+ public function addTorrentDownloadFile(
int $torrentId,
int $userId,
int $added
@@ -672,7 +672,7 @@ class TorrentService
->findTorrentDownloadMagnetsTotalByTorrentId($torrentId);
}
- public function registerTorrentDownloadMagnet(
+ public function addTorrentDownloadMagnet(
int $torrentId,
int $userId,
int $added
diff --git a/templates/default/activity/event/torrent/download/file/add.html.twig b/templates/default/activity/event/torrent/download/file/add.html.twig
new file mode 100644
index 0000000..545b6b3
--- /dev/null
+++ b/templates/default/activity/event/torrent/download/file/add.html.twig
@@ -0,0 +1,12 @@
+
+
+
+
+ {{ 'downloaded torrent file' | trans }}
+
+
+ {{ torrent.name }}
+
+