add torrent approved moderation tools

This commit is contained in:
ghost 2023-10-13 02:28:50 +03:00
parent 92c2a56bbf
commit ed6c4ea415
8 changed files with 513 additions and 207 deletions

View file

@ -43,6 +43,9 @@ class ActivityService
// Torrents
Activity::EVENT_TORRENT_ADD,
Activity::EVENT_TORRENT_APPROVE_ADD,
Activity::EVENT_TORRENT_APPROVE_DELETE,
Activity::EVENT_TORRENT_LOCALES_ADD,
Activity::EVENT_TORRENT_LOCALES_DELETE,
Activity::EVENT_TORRENT_LOCALES_APPROVE_ADD,
@ -191,6 +194,30 @@ class ActivityService
break;
case Activity::EVENT_TORRENT_APPROVE_ADD:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Approved')
] = $code;
break;
case Activity::EVENT_TORRENT_APPROVE_DELETE:
$events
[
$this->translatorInterface->trans('Torrents')
]
[
$this->translatorInterface->trans('Disapproved')
] = $code;
break;
/// Torrent locales
case Activity::EVENT_TORRENT_LOCALES_ADD:
@ -760,6 +787,66 @@ class ActivityService
return $activity;
}
public function addEventTorrentApproveAdd(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_APPROVE_ADD
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
public function addEventTorrentApproveDelete(
int $userId,
int $torrentId,
int $added
): ?Activity
{
$activity = new Activity();
$activity->setEvent(
Activity::EVENT_TORRENT_APPROVE_DELETE
);
$activity->setUserId(
$userId
);
$activity->setTorrentId(
$torrentId
);
$activity->setAdded(
$added
);
$this->entityManagerInterface->persist($activity);
$this->entityManagerInterface->flush();
return $activity;
}
/// Torrent Download
public function addEventTorrentDownloadFileAdd(
int $userId,

View file

@ -298,6 +298,30 @@ class TorrentService
return $torrent;
}
public function toggleTorrentApproved(
int $torrentId
): ?Torrent
{
$torrent = $this->getTorrent($torrentId);
$torrent->setApproved(
!$torrent->isApproved() // 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