mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-03-31 17:15:38 +00:00
add torrent download events #4
This commit is contained in:
parent
964dae97aa
commit
855929f592
6 changed files with 162 additions and 6 deletions
|
|
@ -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:
|
||||
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
[
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue