mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
implement torrent statuses management #28
This commit is contained in:
parent
3cbc6ea90f
commit
989f2f3311
64 changed files with 1051 additions and 282 deletions
|
|
@ -62,6 +62,9 @@ class ActivityService
|
|||
Activity::EVENT_TORRENT_DOWNLOAD_FILE_ADD,
|
||||
Activity::EVENT_TORRENT_DOWNLOAD_MAGNET_ADD,
|
||||
|
||||
Activity::EVENT_TORRENT_STATUS_ADD,
|
||||
Activity::EVENT_TORRENT_STATUS_DELETE,
|
||||
|
||||
Activity::EVENT_TORRENT_WANTED_ADD,
|
||||
];
|
||||
}
|
||||
|
|
@ -379,6 +382,30 @@ class ActivityService
|
|||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
case Activity::EVENT_TORRENT_STATUS_ADD:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrents')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Enabled')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
|
||||
case Activity::EVENT_TORRENT_STATUS_DELETE:
|
||||
|
||||
$events
|
||||
[
|
||||
$this->translatorInterface->trans('Torrents')
|
||||
]
|
||||
[
|
||||
$this->translatorInterface->trans('Disabled')
|
||||
] = $code;
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -861,6 +888,65 @@ class ActivityService
|
|||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentStatusAdd(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_STATUS_ADD
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentStatusDelete(
|
||||
int $userId,
|
||||
int $torrentId,
|
||||
int $added
|
||||
): ?Activity
|
||||
{
|
||||
$activity = new Activity();
|
||||
|
||||
$activity->setEvent(
|
||||
Activity::EVENT_TORRENT_STATUS_DELETE
|
||||
);
|
||||
|
||||
$activity->setUserId(
|
||||
$userId
|
||||
);
|
||||
|
||||
$activity->setTorrentId(
|
||||
$torrentId
|
||||
);
|
||||
|
||||
$activity->setAdded(
|
||||
$added
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($activity);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
return $activity;
|
||||
}
|
||||
|
||||
public function addEventTorrentWantedAdd(
|
||||
int $userId,
|
||||
|
|
|
|||
|
|
@ -192,7 +192,8 @@ class TorrentService
|
|||
int $added,
|
||||
array $locales,
|
||||
bool $sensitive,
|
||||
bool $approved
|
||||
bool $approved,
|
||||
bool $status
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = $this->addTorrent(
|
||||
|
|
@ -204,7 +205,8 @@ class TorrentService
|
|||
),
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved
|
||||
$approved,
|
||||
$status
|
||||
);
|
||||
|
||||
$filesystem = new Filesystem();
|
||||
|
|
@ -249,7 +251,8 @@ class TorrentService
|
|||
array $keywords,
|
||||
array $locales,
|
||||
bool $sensitive,
|
||||
bool $approved
|
||||
bool $approved,
|
||||
bool $status
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = new Torrent();
|
||||
|
|
@ -261,6 +264,7 @@ class TorrentService
|
|||
$torrent->setLocales($locales);
|
||||
$torrent->setSensitive($sensitive);
|
||||
$torrent->setApproved($approved);
|
||||
$torrent->setStatus($status);
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
|
@ -292,6 +296,30 @@ class TorrentService
|
|||
return $torrent;
|
||||
}
|
||||
|
||||
public function toggleTorrentStatus(
|
||||
int $torrentId
|
||||
): ?Torrent
|
||||
{
|
||||
$torrent = $this->getTorrent($torrentId);
|
||||
|
||||
$torrent->setStatus(
|
||||
!$torrent->isStatus() // toggle current value
|
||||
);
|
||||
|
||||
$this->entityManagerInterface->persist($torrent);
|
||||
$this->entityManagerInterface->flush();
|
||||
|
||||
$this->updateTorrentLocales(
|
||||
$torrent->getId()
|
||||
);
|
||||
|
||||
$this->updateTorrentSensitive(
|
||||
$torrent->getId()
|
||||
);
|
||||
|
||||
return $torrent;
|
||||
}
|
||||
|
||||
public function getTorrentScrapeQueue(): ?Torrent
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
|
|
@ -305,40 +333,48 @@ class TorrentService
|
|||
}
|
||||
|
||||
public function findTorrents(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?bool $sensitive,
|
||||
?bool $approved,
|
||||
int $limit,
|
||||
int $offset
|
||||
?bool $status,
|
||||
int $limit,
|
||||
int $offset
|
||||
) : array
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Torrent::class)
|
||||
->findTorrents(
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved,
|
||||
$status,
|
||||
$limit,
|
||||
$offset
|
||||
);
|
||||
}
|
||||
|
||||
public function findTorrentsTotal(
|
||||
int $userId,
|
||||
array $keywords,
|
||||
array $locales,
|
||||
?bool $sensitive,
|
||||
?bool $approved
|
||||
?bool $approved,
|
||||
?bool $status
|
||||
) : int
|
||||
{
|
||||
return $this->entityManagerInterface
|
||||
->getRepository(Torrent::class)
|
||||
->findTorrentsTotal(
|
||||
$userId,
|
||||
$keywords,
|
||||
$locales,
|
||||
$sensitive,
|
||||
$approved
|
||||
$approved,
|
||||
$status
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue