mirror of
https://github.com/YGGverse/YGGtracker.git
synced 2026-04-01 01:25:39 +00:00
init activity features #4
This commit is contained in:
parent
c47c8ad83b
commit
ef84fefca3
27 changed files with 1492 additions and 143 deletions
|
|
@ -11,6 +11,7 @@ use Symfony\Component\HttpFoundation\Request;
|
|||
|
||||
use App\Service\UserService;
|
||||
use App\Service\TorrentService;
|
||||
use App\Service\ActivityService;
|
||||
|
||||
class TorrentController extends AbstractController
|
||||
{
|
||||
|
|
@ -332,7 +333,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -463,7 +465,7 @@ class TorrentController extends AbstractController
|
|||
if (empty($form['locales']['error']))
|
||||
{
|
||||
// Save data
|
||||
$torrentService->addTorrentLocales(
|
||||
$torrentLocales = $torrentService->addTorrentLocales(
|
||||
$torrent->getId(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
|
|
@ -471,6 +473,14 @@ class TorrentController extends AbstractController
|
|||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Register activity event
|
||||
$activityService->addEventTorrentLocalesAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentLocales->getId()
|
||||
);
|
||||
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
|
|
@ -516,7 +526,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService,
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -545,6 +556,27 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Register activity event
|
||||
if (!$torrentLocales->isApproved())
|
||||
{
|
||||
$activityService->addEventTorrentLocalesApproveAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentLocales->getId()
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$activityService->addEventTorrentLocalesApproveDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentLocales->getId()
|
||||
);
|
||||
}
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentLocalesApproved(
|
||||
$torrentLocales->getId()
|
||||
|
|
@ -578,7 +610,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -607,6 +640,14 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Add activity event
|
||||
$activityService->addEventTorrentLocalesDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentLocales->getId()
|
||||
);
|
||||
|
||||
// Update approved
|
||||
$torrentService->deleteTorrentLocales(
|
||||
$torrentLocales->getId()
|
||||
|
|
@ -646,7 +687,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -749,7 +791,7 @@ class TorrentController extends AbstractController
|
|||
if ($request->isMethod('post'))
|
||||
{
|
||||
// Save data
|
||||
$torrentService->addTorrentSensitive(
|
||||
$torrentSensitive = $torrentService->addTorrentSensitive(
|
||||
$torrent->getId(),
|
||||
$user->getId(),
|
||||
time(),
|
||||
|
|
@ -757,6 +799,14 @@ class TorrentController extends AbstractController
|
|||
$user->isApproved()
|
||||
);
|
||||
|
||||
// Add activity event
|
||||
$activityService->addEventTorrentSensitiveAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'torrent_info',
|
||||
|
|
@ -800,7 +850,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -829,6 +880,27 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Add activity event
|
||||
if (!$torrentSensitive->isApproved())
|
||||
{
|
||||
$activityService->addEventTorrentSensitiveApproveAdd(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$activityService->addEventTorrentSensitiveApproveDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
}
|
||||
|
||||
// Update approved
|
||||
$torrentService->toggleTorrentSensitiveApproved(
|
||||
$torrentSensitive->getId()
|
||||
|
|
@ -862,7 +934,8 @@ class TorrentController extends AbstractController
|
|||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService,
|
||||
TorrentService $torrentService
|
||||
TorrentService $torrentService,
|
||||
ActivityService $activityService
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -891,6 +964,14 @@ class TorrentController extends AbstractController
|
|||
);
|
||||
}
|
||||
|
||||
// Add activity event
|
||||
$activityService->addEventTorrentSensitiveDelete(
|
||||
$user->getId(),
|
||||
$torrent->getId(),
|
||||
time(),
|
||||
$torrentSensitive->getId()
|
||||
);
|
||||
|
||||
// Update approved
|
||||
$torrentService->deleteTorrentSensitive(
|
||||
$torrentSensitive->getId()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue