implement user moderation tools

This commit is contained in:
ghost 2023-10-09 19:31:25 +03:00
parent 42cef39589
commit 8d258c677b
5 changed files with 365 additions and 26 deletions

View file

@ -280,6 +280,27 @@ class TorrentService
->getTorrentScrapeQueue();
}
public function setTorrentsApprovedByUserId(
int $userId,
bool $value
): void
{
foreach ($this->entityManagerInterface
->getRepository(Torrent::class)
->findBy(
[
'userId' => $userId
]) as $torrent)
{
$torrent->setApproved(
$value
);
$this->entityManagerInterface->persist($torrent);
$this->entityManagerInterface->flush();
}
}
// Torrent locale
public function getTorrentLocales(int $id): ?TorrentLocales
{
@ -352,6 +373,27 @@ class TorrentService
return $torrentLocales;
}
public function setTorrentLocalesApprovedByUserId(
int $userId,
bool $value
): void
{
foreach ($this->entityManagerInterface
->getRepository(TorrentLocales::class)
->findBy(
[
'userId' => $userId
]) as $torrentLocales)
{
$torrentLocales->setApproved(
$value
);
$this->entityManagerInterface->persist($torrentLocales);
$this->entityManagerInterface->flush();
}
}
// Torrent sensitive
public function getTorrentSensitive(int $id): ?TorrentSensitive
{
@ -424,6 +466,27 @@ class TorrentService
return $torrentSensitive;
}
public function setTorrentSensitivesApprovedByUserId(
int $userId,
bool $value
): void
{
foreach ($this->entityManagerInterface
->getRepository(TorrentSensitive::class)
->findBy(
[
'userId' => $userId
]) as $torrentSensitive)
{
$torrentSensitive->setApproved(
$value
);
$this->entityManagerInterface->persist($torrentSensitive);
$this->entityManagerInterface->flush();
}
}
// Torrent star
public function findTorrentStar(
int $torrentId,