update torrent features

This commit is contained in:
ghost 2023-10-13 00:08:45 +03:00
parent d1f8c126b0
commit e713c17333
16 changed files with 661 additions and 329 deletions

View file

@ -15,6 +15,50 @@ use App\Service\TorrentService;
class ActivityController extends AbstractController
{
#[Route(
'/{_locale}/activity',
name: 'activity_all',
methods:
[
'GET'
]
)]
public function all(
Request $request,
UserService $userService,
ActivityService $activityService
): Response
{
$user = $this->initUser(
$request,
$userService,
$activityService
);
$total = $activityService->findActivitiesTotal(
$user->getEvents()
);
$page = $request->get('page') ? (int) $request->get('page') : 1;
return $this->render(
'default/activity/list.html.twig',
[
'activities' => $activityService->findLastActivities( // @TODO locale/sensitive filters
$user->getEvents(),
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
),
'pagination' =>
[
'page' => $page,
'pages' => ceil($total / $this->getParameter('app.pagination')),
'total' => $total
]
]
);
}
public function event(
$activity,
ActivityService $activityService,
@ -727,4 +771,35 @@ class ActivityController extends AbstractController
);
}
}
private function initUser(
Request $request,
UserService $userService,
ActivityService $activityService
): ?\App\Entity\User
{
// Init user
if (!$user = $userService->findUserByAddress($request->getClientIp()))
{
$user = $userService->addUser(
$request->getClientIp(),
time(),
$this->getParameter('app.locale'),
explode('|', $this->getParameter('app.locales')),
$activityService->getEventCodes(),
$this->getParameter('app.theme'),
$this->getParameter('app.sensitive'),
$this->getParameter('app.yggdrasil'),
$this->getParameter('app.approved')
);
// Add user join event
$activityService->addEventUserAdd(
$user->getId(),
time()
);
}
return $user;
}
}

View file

@ -9,175 +9,21 @@ use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpFoundation\Request;
use App\Service\UserService;
use App\Service\ArticleService;
use App\Service\TorrentService;
use App\Service\ActivityService;
class SearchController extends AbstractController
{
#[Route(
'/{_locale}/search',
name: 'search_index',
methods:
[
'GET'
]
)]
public function index(
Request $request,
UserService $userService,
ArticleService $articleService,
TorrentService $torrentService,
ActivityService $activityService
): Response
{
// Init user
$user = $this->initUser(
$request,
$userService,
$activityService
);
$article = $request->query->get('article') ? (int) $request->query->get('article') : 1;
switch ($request->query->get('type'))
{
case 'article':
break;
case 'torrent':
$total = 0; // @TODO pagination
$torrents = [];
foreach ($torrentService->searchTorrents($request->query->get('query')) as $torrent)
{
// Apply locales filter
if ($lastTorrentLocales = $torrentService->findLastTorrentLocalesByTorrentIdApproved($torrent->getId()))
{
if (!count(
array_intersect(
$lastTorrentLocales->getValue(),
$user->getLocales()
)
)) {
$total--;
continue;
}
}
// Apply sensitive filters
if ($lastTorrentSensitive = $torrentService->findLastTorrentSensitiveByTorrentIdApproved($torrent->getId()))
{
if ($user->isSensitive() && $lastTorrentSensitive->isValue())
{
$total--;
continue;
}
}
// Read file
if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
{
$total--;
continue; // @TODO exception
}
// Generate keywords
$keywords = [];
$query = explode(' ', mb_strtolower($request->query->get('query')));
foreach (explode(',', $torrent->getKeywords()) as $keyword)
{
if (in_array($keyword, $query))
{
$keywords[] = urlencode($keyword);
}
}
$torrents[] =
[
'id' => $torrent->getId(),
'added' => $torrent->getAdded(),
'file' =>
[
'name' => $file->getName(),
'size' => $file->getSize(),
],
'scrape' =>
[
'seeders' => (int) $torrent->getSeeders(),
'peers' => (int) $torrent->getPeers(),
'leechers' => (int) $torrent->getLeechers(),
],
'user' =>
[
'id' => $torrent->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$torrent->getUserId()
)->getAddress()
)
],
'keywords' => $keywords,
'download' =>
[
'file' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadFile(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadFilesTotalByTorrentId(
$torrent->getId()
)
],
'magnet' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadMagnet(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadMagnetsTotalByTorrentId(
$torrent->getId()
)
]
],
'star' =>
[
'exist' => (bool) $torrentService->findTorrentStar(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentStarsTotalByTorrentId(
$torrent->getId()
)
],
];
}
return $this->render('default/search/torrent.html.twig', [
'query' => $request->query->get('query'),
'torrents' => $torrents
]);
break;
default:
throw $this->createNotFoundException();
}
}
public function module(
?string $query,
?string $type
): Response
{
return $this->render('default/search/module.html.twig', [
'query' => $query,
'type' => $type,
]);
return $this->render(
'default/search/module.html.twig',
[
'query' => $query,
]
);
}
private function initUser(

View file

@ -57,27 +57,11 @@ class TorrentController extends AbstractController
// Get contributors
$contributors = [];
$contributors[$torrent->getUserId()] = $userService->identicon(
$userService->getUser(
$torrent->getUserId()
)->getAddress()
);
if ($torrentLocales = $torrentService->findLastTorrentLocalesByTorrentId($torrent->getId()))
foreach ($torrentService->getTorrentContributors($torrent) as $userId)
{
$contributors[$torrentLocales->getUserId()] = $userService->identicon(
$contributors[$userId] = $userService->identicon(
$userService->getUser(
$torrentLocales->getUserId()
)->getAddress()
);
}
if ($torrentSensitive = $torrentService->findLastTorrentSensitiveByTorrentId($torrent->getId()))
{
$contributors[$torrentSensitive->getUserId()] = $userService->identicon(
$userService->getUser(
$torrentSensitive->getUserId()
$userId
)->getAddress()
);
}
@ -98,25 +82,14 @@ class TorrentController extends AbstractController
'id' => $torrent->getId(),
'md5file' => $torrent->getMd5File(),
'added' => $torrent->getAdded(),
/*
'user' =>
[
'id' => $torrent->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$torrent->getUserId()
)->getAddress()
),
],
*/
'scrape' =>
[
'seeders' => (int) $torrent->getSeeders(),
'peers' => (int) $torrent->getPeers(),
'leechers' => (int) $torrent->getLeechers(),
],
'locales' => $torrentService->findLastTorrentLocalesByTorrentId($torrent->getId()),
'sensitive' => $torrentService->findLastTorrentSensitiveByTorrentId($torrent->getId())->isValue(),
'locales' => $torrent->getLocales(),
'sensitive' => $torrent->isSensitive(),
'download' =>
[
'file' =>
@ -172,8 +145,6 @@ class TorrentController extends AbstractController
'v1' => $file->getInfoHashV1(false),
'v2' => $file->getInfoHashV2(false)
],
// @TODO use download action to filter announcement URL
// 'magnet' => $file->getMagnetLink()
],
'trackers' => explode('|', $this->getParameter('app.trackers')),
'activities' => $activityService->findLastActivitiesByTorrentId(
@ -192,7 +163,263 @@ class TorrentController extends AbstractController
}
#[Route(
'/{_locale}/submit/torrent',
'/{_locale}/search',
name: 'torrent_search',
methods:
[
'GET'
]
)]
public function search(
Request $request,
UserService $userService,
TorrentService $torrentService,
ActivityService $activityService
): Response
{
// Init user
$user = $this->initUser(
$request,
$userService,
$activityService
);
// Init request
$query = $request->get('query') ? explode(' ', $request->get('query')) : [];
$page = $request->get('page') ? (int) $request->get('page') : 1;
// Get total torrents
$total = $torrentService->findTorrentsTotal(
$query,
$user->getLocales(),
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
$user->isModerator() ? null : true, // show approved content only for regular users
);
$torrents = [];
foreach ($torrentService->findTorrents(
$query,
$user->getLocales(),
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
$user->isModerator() ? null : true, // show approved content only for regular users
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
{
// Read file
if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
{
throw $this->createNotFoundException(); // @TODO exception
}
// Generate keywords
$keywords = [];
foreach ($torrent->getKeywords() as $keyword)
{
if (in_array($keyword, $query))
{
$keywords[] = urlencode($keyword);
}
}
$torrents[] =
[
'id' => $torrent->getId(),
'added' => $torrent->getAdded(),
'file' =>
[
'name' => $file->getName(),
'size' => $file->getSize(),
],
'scrape' =>
[
'seeders' => (int) $torrent->getSeeders(),
'peers' => (int) $torrent->getPeers(),
'leechers' => (int) $torrent->getLeechers(),
],
'user' =>
[
'id' => $torrent->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$torrent->getUserId()
)->getAddress()
)
],
'keywords' => $keywords,
'download' =>
[
'file' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadFile(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadFilesTotalByTorrentId(
$torrent->getId()
)
],
'magnet' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadMagnet(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadMagnetsTotalByTorrentId(
$torrent->getId()
)
]
],
'star' =>
[
'exist' => (bool) $torrentService->findTorrentStar(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentStarsTotalByTorrentId(
$torrent->getId()
)
],
];
}
return $this->render('default/torrent/list.html.twig', [
'query' => $request->query->get('query'),
'torrents' => $torrents
]);
}
#[Route(
'/{_locale}',
name: 'torrent_recent',
methods:
[
'GET'
]
)]
public function recent(
Request $request,
UserService $userService,
TorrentService $torrentService,
ActivityService $activityService
): Response
{
// Init user
$user = $this->initUser(
$request,
$userService,
$activityService
);
// Init page
$page = $request->get('page') ? (int) $request->get('page') : 1;
// Get total torrents
$total = $torrentService->findTorrentsTotal(
[],
$user->getLocales(),
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
$user->isModerator() ? null : true, // show approved content only for regular users
);
// Create torrents list
$torrents = [];
foreach ($torrentService->findTorrents(
[],
$user->getLocales(),
$user->isSensitive() ? false : null, // hide on sensitive mode enabled or show all
$user->isModerator() ? null : true, // show approved content only for regular users
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
) as $torrent)
{
// Read file
if (!$file = $torrentService->readTorrentFileByTorrentId($torrent->getId()))
{
throw $this->createNotFoundException(); // @TODO exception
}
// Generate keywords
$keywords = [];
$query = explode(' ', mb_strtolower($request->query->get('query')));
foreach ($torrent->getKeywords() as $keyword)
{
if (in_array($keyword, $query))
{
$keywords[] = urlencode($keyword);
}
}
$torrents[] =
[
'id' => $torrent->getId(),
'added' => $torrent->getAdded(),
'file' =>
[
'name' => $file->getName(),
'size' => $file->getSize(),
],
'scrape' =>
[
'seeders' => (int) $torrent->getSeeders(),
'peers' => (int) $torrent->getPeers(),
'leechers' => (int) $torrent->getLeechers(),
],
'user' =>
[
'id' => $torrent->getUserId(),
'identicon' => $userService->identicon(
$userService->getUser(
$torrent->getUserId()
)->getAddress()
)
],
'keywords' => $keywords,
'download' =>
[
'file' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadFile(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadFilesTotalByTorrentId(
$torrent->getId()
)
],
'magnet' =>
[
'exist' => (bool) $torrentService->findTorrentDownloadMagnet(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentDownloadMagnetsTotalByTorrentId(
$torrent->getId()
)
]
],
'star' =>
[
'exist' => (bool) $torrentService->findTorrentStar(
$torrent->getId(),
$user->getId()
),
'total' => $torrentService->findTorrentStarsTotalByTorrentId(
$torrent->getId()
)
],
];
}
return $this->render('default/torrent/list.html.twig', [
'query' => $request->query->get('query'),
'torrents' => $torrents
]);
}
// Forms
#[Route(
'/{_locale}/submit',
name: 'torrent_submit',
methods:
[
@ -310,6 +537,7 @@ class TorrentController extends AbstractController
$user->isApproved()
);
// Add activity event
$activityService->addEventTorrentAdd(
$user->getId(),
time(),
@ -765,7 +993,7 @@ class TorrentController extends AbstractController
}
else
{
if ($torrentSensitive = $torrentService->findLastTorrentSensitiveByTorrentId($request->get('torrentId')))
if ($torrentSensitive = $torrentService->findLastTorrentSensitiveByTorrentId($torrent->getId()))
{
$torrentSensitiveCurrent =
[

View file

@ -31,57 +31,13 @@ class UserController extends AbstractController
);
return $this->redirectToRoute(
'user_dashboard',
'torrent_recent',
[
'_locale' => $user->getLocale()
]
);
}
#[Route(
'/{_locale}',
name: 'user_dashboard',
methods:
[
'GET'
]
)]
public function index(
Request $request,
UserService $userService,
ActivityService $activityService
): Response
{
$user = $this->initUser(
$request,
$userService,
$activityService
);
$total = $activityService->findActivitiesTotal(
$user->getEvents()
);
$page = $request->get('page') ? (int) $request->get('page') : 1;
return $this->render(
'default/user/dashboard.html.twig',
[
'activities' => $activityService->findLastActivities( // @TODO locale/sensitive filters
$user->getEvents(),
$this->getParameter('app.pagination'),
($page - 1) * $this->getParameter('app.pagination')
),
'pagination' =>
[
'page' => $page,
'pages' => ceil($total / $this->getParameter('app.pagination')),
'total' => $total
]
]
);
}
#[Route(
'/{_locale}/settings',
name: 'user_settings',

View file

@ -6,7 +6,6 @@ use App\Repository\TorrentRepository;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
// @TODO #[ORM\Index(columns: ['keywords'], name: 'keywords_idx', flags: ['fulltext'])]
#[ORM\Entity(repositoryClass: TorrentRepository::class)]
class Torrent
@ -25,14 +24,20 @@ class Torrent
#[ORM\Column(nullable: true)]
private ?int $scraped = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $locales = [];
#[ORM\Column]
private ?bool $sensitive = null;
#[ORM\Column]
private ?bool $approved = null;
#[ORM\Column(length: 32)]
private ?string $md5file = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $keywords = null;
#[ORM\Column(type: Types::SIMPLE_ARRAY, nullable: true)]
private ?array $keywords = null;
#[ORM\Column(nullable: true)]
private ?int $seeders = null;
@ -103,18 +108,42 @@ class Torrent
return $this;
}
public function getKeywords(): ?string
public function getKeywords(): ?array
{
return $this->keywords;
}
public function setKeywords(?string $keywords): static
public function setKeywords(?array $keywords): static
{
$this->keywords = $keywords;
return $this;
}
public function getLocales(): array
{
return $this->locales;
}
public function setLocales(array $locales): static
{
$this->locales = $locales;
return $this;
}
public function isSensitive(): ?bool
{
return $this->sensitive;
}
public function setSensitive(bool $sensitive): static
{
$this->sensitive = $sensitive;
return $this;
}
public function isApproved(): ?bool
{
return $this->approved;

View file

@ -23,7 +23,7 @@ class TorrentLocales
#[ORM\Column]
private ?int $added = null;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $value = [];
#[ORM\Column]

View file

@ -32,10 +32,10 @@ class User
#[ORM\Column(length: 2)]
private ?string $locale = null;
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $locales = [];
#[ORM\Column(type: Types::ARRAY)]
#[ORM\Column(type: Types::SIMPLE_ARRAY)]
private array $events = [];
#[ORM\Column(length: 255)]

View file

@ -21,20 +21,94 @@ class TorrentRepository extends ServiceEntityRepository
parent::__construct($registry, Torrent::class);
}
public function searchByKeywords(
array $keywords
): ?array
public function findTorrentsTotal(
array $keywords,
array $locales,
?bool $sensitive = null,
?bool $approved = null,
int $limit = 0,
int $offset = 10
): int
{
$query = $this->createQueryBuilder('t');
return $this->getTorrentsQueryByFilter(
$keywords,
$locales,
$sensitive,
$approved,
)->select('count(t.id)')
->getQuery()
->getSingleScalarResult();
}
foreach ($keywords as $keyword)
{
$query->orWhere('t.keywords LIKE :query')
->setParameter('query', "%{$keyword}%");
}
return $query->orderBy('t.id', 'ASC') // same as t.added
public function findTorrents(
array $keywords,
array $locales,
?bool $sensitive = null,
?bool $approved = null,
int $limit = 0,
int $offset = 10
): array
{
return $this->getTorrentsQueryByFilter(
$keywords,
$locales,
$sensitive,
$approved,
)->setMaxResults($limit)
->setFirstResult($offset)
->orderBy('t.id', 'DESC') // same as t.added
->getQuery()
->getResult();
}
private function getTorrentsQueryByFilter(
array $keywords,
array $locales,
?bool $sensitive = null,
?bool $approved = null,
): \Doctrine\ORM\QueryBuilder
{
$query = $this->createQueryBuilder('t');
if ($keywords) // @TODO ANY or DTS
{
$orX = $query->expr()->orX();
foreach ($keywords as $i => $keyword)
{
$orX->add("t.keywords LIKE :keyword{$i}");
$query->setParameter(":keyword{$i}", "%{$keyword}%");
}
$query->andWhere($orX);
}
if ($locales) // @TODO ANY or DTS
{
$orX = $query->expr()->orX();
foreach ($locales as $i => $locale)
{
$orX->add("t.locales LIKE :locale{$i}");
$query->setParameter(":locale{$i}", "%{$locale}%");
}
$query->andWhere($orX);
}
if (is_bool($sensitive))
{
$query->andWhere('t.sensitive = :sensitive')
->setParameter('sensitive', $sensitive);
}
if (is_bool($approved))
{
$query->andWhere('t.approved = :approved')
->setParameter('approved', $approved);
}
return $query;
}
}

View file

@ -150,7 +150,7 @@ class TorrentService
public function generateTorrentKeywordsByTorrentFilepath(
string $filepath,
int $minLength = 3
): string
): array
{
$keywords = [];
@ -175,17 +175,17 @@ class TorrentService
{
unset($words[$key]);
}
else
{
$words[$key] = mb_strtolower($value);
}
}
$keywords = array_merge($keywords, $words);
}
return mb_strtolower(
implode(
',',
array_unique($keywords)
)
);
return array_unique($keywords);
}
public function getStorageFilepathById(int $id): string
@ -197,6 +197,25 @@ class TorrentService
);
}
public function getTorrentContributors(Torrent $torrent): array
{
$contributors = [];
foreach ($this->findTorrentLocalesByTorrentId($torrent->getUserId()) as $torrentLocale)
{
$contributors[] = $torrentLocale->getUserId();
}
foreach ($this->findTorrentSensitiveByTorrentId($torrent->getUserId()) as $torrentSensitive)
{
$contributors[] = $torrentSensitive->getUserId();
}
$contributors[] = $torrent->getUserId();
return array_unique($contributors);
}
public function add(
string $filepath,
int $userId,
@ -213,6 +232,8 @@ class TorrentService
$this->generateTorrentKeywordsByTorrentFilepath(
$filepath
),
$locales,
$sensitive,
$approved
);
@ -224,16 +245,13 @@ class TorrentService
)
);
if (!empty($locales))
{
$this->addTorrentLocales(
$torrent->getId(),
$userId,
$added,
$locales,
$approved
);
}
$this->addTorrentLocales(
$torrent->getId(),
$userId,
$added,
$locales,
$approved
);
$this->addTorrentSensitive(
$torrent->getId(),
@ -258,7 +276,9 @@ class TorrentService
int $userId,
int $added,
string $md5file,
string $keywords,
array $keywords,
array $locales,
bool $sensitive,
bool $approved
): ?Torrent
{
@ -268,6 +288,8 @@ class TorrentService
$torrent->setAdded($added);
$torrent->setMd5File($md5file);
$torrent->setKeywords($keywords);
$torrent->setLocales($locales);
$torrent->setSensitive($sensitive);
$torrent->setApproved($approved);
$this->entityManagerInterface->persist($torrent);
@ -288,12 +310,41 @@ class TorrentService
);
}
public function searchTorrents(string $query) : array
public function findTorrents(
array $keywords,
array $locales,
?bool $sensitive,
?bool $approved,
int $limit,
int $offset
) : array
{
return $this->entityManagerInterface
->getRepository(Torrent::class)
->searchByKeywords(
explode(' ', $query)
->findTorrents(
$keywords,
$locales,
$sensitive,
$approved,
$limit,
$offset
);
}
public function findTorrentsTotal(
array $keywords,
array $locales,
?bool $sensitive,
?bool $approved
) : int
{
return $this->entityManagerInterface
->getRepository(Torrent::class)
->findTorrentsTotal(
$keywords,
$locales,
$sensitive,
$approved
);
}
@ -308,6 +359,74 @@ class TorrentService
);
}
public function updateTorrentSensitive(
int $torrentId,
): void
{
if ($torrent = $this->getTorrent($torrentId))
{
if ($torrentSensitive = $this->entityManagerInterface
->getRepository(TorrentSensitive::class)
->findOneBy(
[
'torrentId' => $torrentId,
'approved' => true,
],
[
'id' => 'DESC'
]
))
{
$torrent->setSensitive(
$torrentSensitive->isValue()
);
$this->entityManagerInterface->persist($torrent);
$this->entityManagerInterface->flush();
}
}
}
public function updateTorrentLocales(
int $torrentId
): void
{
if ($torrent = $this->getTorrent($torrentId))
{
if ($torrentLocales = $this->entityManagerInterface
->getRepository(TorrentLocales::class)
->findOneBy(
[
'torrentId' => $torrentId,
'approved' => true,
],
[
'id' => 'DESC'
]
))
{
$torrent->setLocales($torrentLocales->getValue());
$this->entityManagerInterface->persist($torrent);
$this->entityManagerInterface->flush();
}
}
}
public function setTorrentApprovedByTorrentId(
int $torrentId,
bool $value
): void
{
if ($torrent = $this->getTorrent($torrentId))
{
$torrent->setApproved($value);
$this->entityManagerInterface->persist($torrent);
$this->entityManagerInterface->flush();
}
}
public function setTorrentsApprovedByUserId(
int $userId,
bool $value
@ -355,24 +474,6 @@ class TorrentService
);
}
public function findLastTorrentLocalesByTorrentIdApproved(
int $torrentId,
bool $approved = true
): ?TorrentLocales
{
return $this->entityManagerInterface
->getRepository(TorrentLocales::class)
->findOneBy(
[
'torrentId' => $torrentId,
'approved' => $approved
],
[
'id' => 'DESC'
]
);
}
public function findTorrentLocalesByTorrentId(int $torrentId): array
{
return $this->entityManagerInterface
@ -400,6 +501,10 @@ class TorrentService
$this->entityManagerInterface->persist($torrentLocales);
$this->entityManagerInterface->flush();
$this->updateTorrentLocales(
$torrentLocales->getTorrentId()
);
return $torrentLocales;
}
@ -412,6 +517,10 @@ class TorrentService
$this->entityManagerInterface->remove($torrentLocales);
$this->entityManagerInterface->flush();
$this->updateTorrentLocales(
$torrentLocales->getTorrentId()
);
return $torrentLocales;
}
@ -434,6 +543,10 @@ class TorrentService
$this->entityManagerInterface->persist($torrentLocales);
$this->entityManagerInterface->flush();
$this->updateTorrentLocales(
$torrentId
);
return $torrentLocales;
}
@ -484,24 +597,6 @@ class TorrentService
);
}
public function findLastTorrentSensitiveByTorrentIdApproved(
int $torrentId,
bool $approved = true
): ?TorrentSensitive
{
return $this->entityManagerInterface
->getRepository(TorrentSensitive::class)
->findOneBy(
[
'torrentId' => $torrentId,
'approved' => $approved,
],
[
'id' => 'DESC'
]
);
}
public function findTorrentSensitiveByTorrentId(int $torrentId): array
{
return $this->entityManagerInterface
@ -531,6 +626,10 @@ class TorrentService
$this->entityManagerInterface->persist($torrentSensitive);
$this->entityManagerInterface->flush();
$this->updateTorrentSensitive(
$torrentSensitive->getTorrentId()
);
return $torrentSensitive;
}
@ -545,6 +644,10 @@ class TorrentService
$this->entityManagerInterface->remove($torrentSensitive);
$this->entityManagerInterface->flush();
$this->updateTorrentSensitive(
$torrentSensitive->getTorrentId()
);
return $torrentSensitive;
}
@ -567,6 +670,10 @@ class TorrentService
$this->entityManagerInterface->persist($torrentSensitive);
$this->entityManagerInterface->flush();
$this->updateTorrentSensitive(
$torrentId
);
return $torrentSensitive;
}