mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2025-02-02 01:54:13 +00:00
add torrent download events #4
This commit is contained in:
parent
964dae97aa
commit
855929f592
@ -330,6 +330,61 @@ class ActivityController extends AbstractController
|
|||||||
|
|
||||||
break;
|
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
|
/// Torrent Locales
|
||||||
case $activity::EVENT_TORRENT_LOCALES_ADD:
|
case $activity::EVENT_TORRENT_LOCALES_ADD:
|
||||||
|
|
||||||
|
@ -1088,7 +1088,8 @@ class TorrentController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
TorrentService $torrentService
|
TorrentService $torrentService,
|
||||||
|
ActivityService $activityService
|
||||||
): Response
|
): Response
|
||||||
{
|
{
|
||||||
// Init user
|
// Init user
|
||||||
@ -1119,12 +1120,19 @@ class TorrentController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register download
|
// Register download
|
||||||
$torrentService->registerTorrentDownloadFile(
|
$torrentService->addTorrentDownloadFile(
|
||||||
$torrent->getId(),
|
$torrent->getId(),
|
||||||
$user->getId(),
|
$user->getId(),
|
||||||
time()
|
time()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Register download event
|
||||||
|
$activityService->addEventTorrentDownloadFileAdd(
|
||||||
|
$user->getId(),
|
||||||
|
time(),
|
||||||
|
$torrent->getId()
|
||||||
|
);
|
||||||
|
|
||||||
// Filter trackers
|
// Filter trackers
|
||||||
$file->setAnnounceList(
|
$file->setAnnounceList(
|
||||||
[
|
[
|
||||||
@ -1183,7 +1191,8 @@ class TorrentController extends AbstractController
|
|||||||
Request $request,
|
Request $request,
|
||||||
TranslatorInterface $translator,
|
TranslatorInterface $translator,
|
||||||
UserService $userService,
|
UserService $userService,
|
||||||
TorrentService $torrentService
|
TorrentService $torrentService,
|
||||||
|
ActivityService $activityService
|
||||||
): Response
|
): Response
|
||||||
{
|
{
|
||||||
// Init user
|
// Init user
|
||||||
@ -1214,12 +1223,19 @@ class TorrentController extends AbstractController
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Register download
|
// Register download
|
||||||
$torrentService->registerTorrentDownloadMagnet(
|
$torrentService->addTorrentDownloadMagnet(
|
||||||
$torrent->getId(),
|
$torrent->getId(),
|
||||||
$user->getId(),
|
$user->getId(),
|
||||||
time()
|
time()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Register download event
|
||||||
|
$activityService->addEventTorrentDownloadMagnetAdd(
|
||||||
|
$user->getId(),
|
||||||
|
time(),
|
||||||
|
$torrent->getId()
|
||||||
|
);
|
||||||
|
|
||||||
// Filter trackers
|
// Filter trackers
|
||||||
$file->setAnnounceList(
|
$file->setAnnounceList(
|
||||||
[
|
[
|
||||||
|
@ -151,6 +151,67 @@ class ActivityService
|
|||||||
return $activity;
|
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
|
/// Torrent star
|
||||||
public function addEventTorrentStarAdd(
|
public function addEventTorrentStarAdd(
|
||||||
int $userId,
|
int $userId,
|
||||||
|
@ -630,7 +630,7 @@ class TorrentService
|
|||||||
->findTorrentDownloadFilesTotalByTorrentId($torrentId);
|
->findTorrentDownloadFilesTotalByTorrentId($torrentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerTorrentDownloadFile(
|
public function addTorrentDownloadFile(
|
||||||
int $torrentId,
|
int $torrentId,
|
||||||
int $userId,
|
int $userId,
|
||||||
int $added
|
int $added
|
||||||
@ -672,7 +672,7 @@ class TorrentService
|
|||||||
->findTorrentDownloadMagnetsTotalByTorrentId($torrentId);
|
->findTorrentDownloadMagnetsTotalByTorrentId($torrentId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function registerTorrentDownloadMagnet(
|
public function addTorrentDownloadMagnet(
|
||||||
int $torrentId,
|
int $torrentId,
|
||||||
int $userId,
|
int $userId,
|
||||||
int $added
|
int $added
|
||||||
|
@ -0,0 +1,12 @@
|
|||||||
|
<a href="{{ path('user_info', { userId : user.id }) }}">
|
||||||
|
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
|
||||||
|
</a>
|
||||||
|
<span class="margin-x-4-px">
|
||||||
|
{{ 'downloaded torrent file' | trans }}
|
||||||
|
</span>
|
||||||
|
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
|
||||||
|
{{ torrent.name }}
|
||||||
|
</a>
|
||||||
|
<div class="float-right">
|
||||||
|
{{ added | format_ago }}
|
||||||
|
</div>
|
@ -0,0 +1,12 @@
|
|||||||
|
<a href="{{ path('user_info', { userId : user.id }) }}">
|
||||||
|
<img class="border-radius-50 border-color-default vertical-align-middle" src="{{ user.identicon }}" alt="{{ 'identicon' | trans }}" />
|
||||||
|
</a>
|
||||||
|
<span class="margin-x-4-px">
|
||||||
|
{{ 'downloaded magnet link' | trans }}
|
||||||
|
</span>
|
||||||
|
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
|
||||||
|
{{ torrent.name }}
|
||||||
|
</a>
|
||||||
|
<div class="float-right">
|
||||||
|
{{ added | format_ago }}
|
||||||
|
</div>
|
Loading…
x
Reference in New Issue
Block a user