|
|
@ -161,16 +161,21 @@ class TorrentService |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/// Bookmark |
|
|
|
/// Bookmark |
|
|
|
public function findUserLastTorrentBookmarkValue(int $torrentId, int $userId): bool |
|
|
|
public function findTorrentBookmark( |
|
|
|
|
|
|
|
int $torrentId, |
|
|
|
|
|
|
|
int $userId |
|
|
|
|
|
|
|
): ?TorrentBookmark |
|
|
|
{ |
|
|
|
{ |
|
|
|
if ($torrentBookmark = $this->entityManagerInterface |
|
|
|
return $this->entityManagerInterface |
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
->findUserLastTorrentBookmark($torrentId, $userId)) |
|
|
|
->findTorrentBookmark($torrentId, $userId); |
|
|
|
{ |
|
|
|
|
|
|
|
return $torrentBookmark->isValue(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
public function findTorrentBookmarksTotalByTorrentId(int $torrentId): int |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return $this->entityManagerInterface |
|
|
|
|
|
|
|
->getRepository(TorrentBookmark::class) |
|
|
|
|
|
|
|
->findTorrentBookmarksTotalByTorrentId($torrentId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Update |
|
|
|
// Update |
|
|
@ -223,7 +228,15 @@ class TorrentService |
|
|
|
int $torrentId, |
|
|
|
int $torrentId, |
|
|
|
int $userId, |
|
|
|
int $userId, |
|
|
|
int $added |
|
|
|
int $added |
|
|
|
): ?TorrentBookmark |
|
|
|
): void |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if ($torrentBookmark = $this->findTorrentBookmark($torrentId, $userId)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
$this->entityManagerInterface->remove($torrentBookmark); |
|
|
|
|
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
else |
|
|
|
{ |
|
|
|
{ |
|
|
|
$torrentBookmark = new TorrentBookmark(); |
|
|
|
$torrentBookmark = new TorrentBookmark(); |
|
|
|
|
|
|
|
|
|
|
@ -231,17 +244,9 @@ class TorrentService |
|
|
|
$torrentBookmark->setUserId($userId); |
|
|
|
$torrentBookmark->setUserId($userId); |
|
|
|
$torrentBookmark->setAdded($added); |
|
|
|
$torrentBookmark->setAdded($added); |
|
|
|
|
|
|
|
|
|
|
|
$torrentBookmark->setValue( |
|
|
|
|
|
|
|
!$this->findUserLastTorrentBookmarkValue( |
|
|
|
|
|
|
|
$torrentId, |
|
|
|
|
|
|
|
$userId |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$this->entityManagerInterface->persist($torrentBookmark); |
|
|
|
$this->entityManagerInterface->persist($torrentBookmark); |
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
$this->entityManagerInterface->flush(); |
|
|
|
|
|
|
|
} |
|
|
|
return $torrentBookmark; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function deleteTorrentSensitive( |
|
|
|
public function deleteTorrentSensitive( |
|
|
|