Browse Source

add wanted events support #27

main
ghost 1 year ago
parent
commit
24c58d4301
  1. 38
      src/Controller/ActivityController.php
  2. 11
      src/Controller/TorrentController.php
  3. 2
      src/Entity/Activity.php
  4. 45
      src/Service/ActivityService.php
  5. 23
      templates/default/activity/event/torrent/wanted/add.html.twig
  6. 17
      templates/default/activity/event/torrent/wanted/add.rss.twig
  7. 8
      translations/messages+intl-icu.cs.xlf
  8. 8
      translations/messages+intl-icu.de.xlf
  9. 8
      translations/messages+intl-icu.en.xlf
  10. 8
      translations/messages+intl-icu.eo.xlf
  11. 8
      translations/messages+intl-icu.es.xlf
  12. 8
      translations/messages+intl-icu.fr.xlf
  13. 8
      translations/messages+intl-icu.he.xlf
  14. 8
      translations/messages+intl-icu.it.xlf
  15. 8
      translations/messages+intl-icu.ka.xlf
  16. 8
      translations/messages+intl-icu.lv.xlf
  17. 8
      translations/messages+intl-icu.pl.xlf
  18. 8
      translations/messages+intl-icu.pt.xlf
  19. 8
      translations/messages+intl-icu.ru.xlf
  20. 10
      translations/messages+intl-icu.uk.xlf

38
src/Controller/ActivityController.php

@ -764,6 +764,44 @@ class ActivityController extends AbstractController @@ -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:

11
src/Controller/TorrentController.php

@ -2191,6 +2191,17 @@ class TorrentController extends AbstractController @@ -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(),

2
src/Entity/Activity.php

@ -57,6 +57,8 @@ class Activity @@ -57,6 +57,8 @@ class Activity
public const EVENT_TORRENT_DOWNLOAD_MAGNET_ADD = 2600;
public const EVENT_TORRENT_WANTED_ADD = 2700;
// ...
#[ORM\Column]

45
src/Service/ActivityService.php

@ -61,6 +61,8 @@ class ActivityService @@ -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 @@ -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 @@ -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,

23
templates/default/activity/event/torrent/wanted/add.html.twig

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
<div class="row">
<div class="column width-80">
<span class="margin-l-4-px">
{{ 'seeders wanted for torrent' | trans }}
</span>
{% if session.user.moderator or session.user.owner %}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
{% else %}
{% if torrent.sensitive == true %}
#{{ torrent.id }} ({{ 'sensitive' | trans }})
{% else %}
<a href="{{ path('torrent_info', { torrentId : torrent.id }) }}">
{{ torrent.name }}
</a>
{% endif %}
{% endif %}
</div>
<div class="column width-20 text-right">
{{ added | format_ago }}
</div>
</div>

17
templates/default/activity/event/torrent/wanted/add.rss.twig

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<item>
<title>
{{ '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 %}
</title>
<pubDate>{{ added | date('D, d M Y h:i:s O') }}</pubDate>
<guid>{{ url('torrent_info', { torrentId : torrent.id }) }}#activity-{{ id }}</guid>
<link>{{ url('torrent_info', { torrentId : torrent.id }) }}#activity</link>
</item>

8
translations/messages+intl-icu.cs.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.de.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.en.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.eo.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.es.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.fr.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.he.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.it.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.ka.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.lv.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.pl.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.pt.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Upload</a> any torrent - download with Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Wanted</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>seeders wanted for torrent</target>
</trans-unit>
</body>
</file>
</xliff>

8
translations/messages+intl-icu.ru.xlf

@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Загрузить</a> любой торрент - скачать с Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Розыск</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>требуется раздача для торрента</target>
</trans-unit>
</body>
</file>
</xliff>

10
translations/messages+intl-icu.uk.xlf

@ -163,7 +163,7 @@ @@ -163,7 +163,7 @@
</trans-unit>
<trans-unit id="ypBmhzv" resname="wanted">
<source>wanted</source>
<target>розшукується</target>
<target>розшук</target>
</trans-unit>
<trans-unit id="R138zpi" resname="Waiting for approve">
<source>Waiting for approve</source>
@ -721,6 +721,14 @@ @@ -721,6 +721,14 @@
<source>&lt;a href="%s"&gt;Upload&lt;/a&gt; any torrent - download with Yggdrasil</source>
<target><![CDATA[<a href="%s">Надіслати</a> будь-який торент - завантажити з Yggdrasil]]></target>
</trans-unit>
<trans-unit id="wpaDJlY" resname="Wanted">
<source>Wanted</source>
<target>Розшук</target>
</trans-unit>
<trans-unit id="B95C5DS" resname="seeders wanted for torrent">
<source>seeders wanted for torrent</source>
<target>розшукуються роздачі для торенту</target>
</trans-unit>
</body>
</file>
</xliff>

Loading…
Cancel
Save