diff --git a/src/Controller/ActivityController.php b/src/Controller/ActivityController.php index 2f62d78..4ac57f1 100644 --- a/src/Controller/ActivityController.php +++ b/src/Controller/ActivityController.php @@ -764,6 +764,44 @@ class ActivityController extends AbstractController break; + // Torrent Wanted + case $activity::EVENT_TORRENT_WANTED_ADD: + + // Init torrent + if (!$torrent = $torrentService->getTorrent($activity->getTorrentId())) + { + throw $this->createNotFoundException(); + } + + return $this->render( + 'default/activity/event/torrent/wanted/add' . $extension, + [ + 'id' => $activity->getId(), + 'added' => $activity->getAdded(), + 'torrent' => + [ + 'id' => $torrent->getId(), + 'sensitive' => $torrent->isSensitive(), + 'approved' => $torrent->isApproved(), + 'name' => $torrentService->readTorrentFileByTorrentId( + $torrent->getId() + )->getName() + ], + 'session' => + [ + 'user' => + [ + 'id' => $user->getId(), + 'sensitive' => $user->isSensitive(), + 'moderator' => $user->isModerator(), + 'owner' => $user->getId() === $torrent->getUserId(), + ] + ] + ] + ); + + break; + /// Torrent Locales case $activity::EVENT_TORRENT_LOCALES_ADD: diff --git a/src/Controller/TorrentController.php b/src/Controller/TorrentController.php index 09e9755..8027390 100644 --- a/src/Controller/TorrentController.php +++ b/src/Controller/TorrentController.php @@ -2191,6 +2191,17 @@ class TorrentController extends AbstractController } } + // Register activity event only on previous status changed + if ($leechers && !$seeders && + $leechers != (int) $torrent->getLeechers() && $seeders != (int) $torrent->getSeeders()) + { + $activityService->addEventTorrentWantedAdd( + $torrent->getUserId(), // just required field, let's relate with author, because we don't know which exactly user requires for seeders from crontab @TODO + time(), + $torrent->getId() + ); + } + // Update DB $torrentService->updateTorrentScrape( $torrent->getId(), diff --git a/src/Entity/Activity.php b/src/Entity/Activity.php index a08cfcb..3b208b9 100644 --- a/src/Entity/Activity.php +++ b/src/Entity/Activity.php @@ -57,6 +57,8 @@ class Activity public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600; + public const EVENT_TORRENT_WANTED_ADD = 2700; + // ... #[ORM\Column] diff --git a/src/Service/ActivityService.php b/src/Service/ActivityService.php index 14eaa9f..4dbbb74 100644 --- a/src/Service/ActivityService.php +++ b/src/Service/ActivityService.php @@ -61,6 +61,8 @@ class ActivityService Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD, Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD, + + Activity::EVENT_TORRENT_WANTED_ADD, ]; } @@ -365,6 +367,18 @@ class ActivityService ] = $code; break; + + case Activity::EVENT_TORRENT_WANTED_ADD: + + $events + [ + $this->translatorInterface->trans('Torrents') + ] + [ + $this->translatorInterface->trans('Wanted') + ] = $code; + + break; } } @@ -847,6 +861,37 @@ class ActivityService return $activity; } + + public function addEventTorrentWantedAdd( + int $userId, + int $added, + int $torrentId + ): ?Activity + { + $activity = new Activity(); + + $activity->setEvent( + Activity::EVENT_TORRENT_WANTED_ADD + ); + + $activity->setUserId( + $userId + ); + + $activity->setAdded( + $added + ); + + $activity->setTorrentId( + $torrentId + ); + + $this->entityManagerInterface->persist($activity); + $this->entityManagerInterface->flush(); + + return $activity; + } + /// Torrent Download public function addEventTorrentDownloadFileAdd( int $userId, diff --git a/templates/default/activity/event/torrent/wanted/add.html.twig b/templates/default/activity/event/torrent/wanted/add.html.twig new file mode 100644 index 0000000..06c14a5 --- /dev/null +++ b/templates/default/activity/event/torrent/wanted/add.html.twig @@ -0,0 +1,23 @@ +
+
+ + {{ 'seeders wanted for torrent' | trans }} + + {% if session.user.moderator or session.user.owner %} + + {{ torrent.name }} + + {% else %} + {% if torrent.sensitive == true %} + #{{ torrent.id }} ({{ 'sensitive' | trans }}) + {% else %} + + {{ torrent.name }} + + {% endif %} + {% endif %} +
+
+ {{ added | format_ago }} +
+
\ No newline at end of file diff --git a/templates/default/activity/event/torrent/wanted/add.rss.twig b/templates/default/activity/event/torrent/wanted/add.rss.twig new file mode 100644 index 0000000..1fdbc7c --- /dev/null +++ b/templates/default/activity/event/torrent/wanted/add.rss.twig @@ -0,0 +1,17 @@ + + + {{ 'seeders wanted for torrent' | trans }} + {% if session.user.moderator or session.user.owner %} + {{ torrent.name }} + {% else %} + {% if torrent.sensitive == true %} + #{{ torrent.id }} ({{ 'sensitive' | trans }}) + {% else %} + {{ torrent.name }} + {% endif %} + {% endif %} + + {{ added | date('D, d M Y h:i:s O') }} + {{ url('torrent_info', { torrentId : torrent.id }) }}#activity-{{ id }} + {{ url('torrent_info', { torrentId : torrent.id }) }}#activity + \ No newline at end of file diff --git a/translations/messages+intl-icu.cs.xlf b/translations/messages+intl-icu.cs.xlf index e0d8492..c837042 100644 --- a/translations/messages+intl-icu.cs.xlf +++ b/translations/messages+intl-icu.cs.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.de.xlf b/translations/messages+intl-icu.de.xlf index 35bf7af..9bca1ae 100644 --- a/translations/messages+intl-icu.de.xlf +++ b/translations/messages+intl-icu.de.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.en.xlf b/translations/messages+intl-icu.en.xlf index 8c517f2..59d282a 100644 --- a/translations/messages+intl-icu.en.xlf +++ b/translations/messages+intl-icu.en.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.eo.xlf b/translations/messages+intl-icu.eo.xlf index bb305f8..15d4350 100644 --- a/translations/messages+intl-icu.eo.xlf +++ b/translations/messages+intl-icu.eo.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.es.xlf b/translations/messages+intl-icu.es.xlf index 81efda9..0f475db 100644 --- a/translations/messages+intl-icu.es.xlf +++ b/translations/messages+intl-icu.es.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.fr.xlf b/translations/messages+intl-icu.fr.xlf index e028741..097d28f 100644 --- a/translations/messages+intl-icu.fr.xlf +++ b/translations/messages+intl-icu.fr.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.he.xlf b/translations/messages+intl-icu.he.xlf index cf0fde6..8435131 100644 --- a/translations/messages+intl-icu.he.xlf +++ b/translations/messages+intl-icu.he.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.it.xlf b/translations/messages+intl-icu.it.xlf index 1e57b99..aba8add 100644 --- a/translations/messages+intl-icu.it.xlf +++ b/translations/messages+intl-icu.it.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.ka.xlf b/translations/messages+intl-icu.ka.xlf index 1c5e2e3..a84f766 100644 --- a/translations/messages+intl-icu.ka.xlf +++ b/translations/messages+intl-icu.ka.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.lv.xlf b/translations/messages+intl-icu.lv.xlf index c938aed..fd5488d 100644 --- a/translations/messages+intl-icu.lv.xlf +++ b/translations/messages+intl-icu.lv.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.pl.xlf b/translations/messages+intl-icu.pl.xlf index da866bf..f151ff6 100644 --- a/translations/messages+intl-icu.pl.xlf +++ b/translations/messages+intl-icu.pl.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.pt.xlf b/translations/messages+intl-icu.pt.xlf index 9a8e985..a5c6465 100644 --- a/translations/messages+intl-icu.pt.xlf +++ b/translations/messages+intl-icu.pt.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Upload any torrent - download with Yggdrasil]]> + + Wanted + Wanted + + + seeders wanted for torrent + seeders wanted for torrent + diff --git a/translations/messages+intl-icu.ru.xlf b/translations/messages+intl-icu.ru.xlf index 2af8787..c816722 100644 --- a/translations/messages+intl-icu.ru.xlf +++ b/translations/messages+intl-icu.ru.xlf @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Загрузить любой торрент - скачать с Yggdrasil]]> + + Wanted + Розыск + + + seeders wanted for torrent + требуется раздача для торрента + diff --git a/translations/messages+intl-icu.uk.xlf b/translations/messages+intl-icu.uk.xlf index 8575ff2..aca1774 100644 --- a/translations/messages+intl-icu.uk.xlf +++ b/translations/messages+intl-icu.uk.xlf @@ -163,7 +163,7 @@ wanted - розшукується + розшук Waiting for approve @@ -721,6 +721,14 @@ <a href="%s">Upload</a> any torrent - download with Yggdrasil Надіслати будь-який торент - завантажити з Yggdrasil]]> + + Wanted + Розшук + + + seeders wanted for torrent + розшукуються роздачі для торенту +