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
620
src/Controller/ActivityController.php
Normal file
620
src/Controller/ActivityController.php
Normal file
|
|
@ -0,0 +1,620 @@
|
|||
<?php
|
||||
|
||||
namespace App\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||
|
||||
use Symfony\Component\Routing\Annotation\Route;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
use App\Service\ActivityService;
|
||||
use App\Service\UserService;
|
||||
use App\Service\ArticleService;
|
||||
use App\Service\TorrentService;
|
||||
|
||||
class ActivityController extends AbstractController
|
||||
{
|
||||
public function template(
|
||||
$activity,
|
||||
ActivityService $activityService,
|
||||
UserService $userService,
|
||||
ArticleService $articleService,
|
||||
TorrentService $torrentService,
|
||||
): Response
|
||||
{
|
||||
switch ($activity->getEvent())
|
||||
{
|
||||
// User
|
||||
case $activity::EVENT_USER_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_APPROVE_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/approve/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_APPROVE_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/approve/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_MODERATOR_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/moderator/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_MODERATOR_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/moderator/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_STATUS_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/status/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_STATUS_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/status/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_STAR_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/star/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_USER_STAR_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/user/star/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'by' =>
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getData()['userId'],
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getData()['userId']
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
// Torrent
|
||||
case $activity::EVENT_TORRENT_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName()
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
/// Torrent Locales
|
||||
case $activity::EVENT_TORRENT_LOCALES_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_LOCALES_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_LOCALES_APPROVE_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/approve/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_LOCALES_APPROVE_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/locales/approve/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'locales' => [
|
||||
'id' => $activity->getData()['torrentLocalesId'],
|
||||
'exist' => $torrentService->getTorrentLocales(
|
||||
$activity->getData()['torrentLocalesId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
/// Torrent Sensitive
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_ADD:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/approve/add.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
case $activity::EVENT_TORRENT_SENSITIVE_APPROVE_DELETE:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/torrent/sensitive/approve/delete.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
],
|
||||
'torrent' =>
|
||||
[
|
||||
'id' => $activity->getTorrentId(),
|
||||
'name' => $torrentService->readTorrentFileByTorrentId(
|
||||
$activity->getTorrentId()
|
||||
)->getName(),
|
||||
'sensitive' => [
|
||||
'id' => $activity->getData()['torrentSensitiveId'],
|
||||
'exist' => $torrentService->getTorrentSensitive(
|
||||
$activity->getData()['torrentSensitiveId'] // could be deleted by moderator, remove links
|
||||
)
|
||||
]
|
||||
]
|
||||
]
|
||||
);
|
||||
|
||||
break;
|
||||
|
||||
// Page
|
||||
|
||||
default:
|
||||
|
||||
return $this->render(
|
||||
'default/activity/event/undefined.html.twig',
|
||||
[
|
||||
'added' => $activity->getAdded(),
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activity->getUserId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$userService->getUser(
|
||||
$activity->getUserId()
|
||||
)->getAddress()
|
||||
)
|
||||
]
|
||||
]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -44,46 +44,10 @@ class UserController extends AbstractController
|
|||
UserService $userService
|
||||
): Response
|
||||
{
|
||||
// Init user session
|
||||
$user = $userService->init(
|
||||
$request->getClientIp()
|
||||
);
|
||||
|
||||
// Build activity history
|
||||
$activities = [];
|
||||
|
||||
/*
|
||||
foreach ($activityService->findLast($user->isModerator()) as $activity)
|
||||
{
|
||||
if (!$activity->getUserId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
$activityUser = $userService->getUser(
|
||||
$activity->getUserId()
|
||||
);
|
||||
|
||||
$activities[] =
|
||||
[
|
||||
'user' =>
|
||||
[
|
||||
'id' => $activityUser->getId(),
|
||||
'identicon' => $userService->identicon(
|
||||
$activityUser->getAddress(),
|
||||
24
|
||||
)
|
||||
],
|
||||
'type' => 'join',
|
||||
'added' => $activity->getAdded()
|
||||
];
|
||||
}
|
||||
*/
|
||||
|
||||
return $this->render(
|
||||
'default/user/dashboard.html.twig',
|
||||
[
|
||||
'activities' => $activities
|
||||
'activities' => $activityService->findLastActivities()
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
@ -271,7 +235,8 @@ class UserController extends AbstractController
|
|||
public function toggleStar(
|
||||
Request $request,
|
||||
TranslatorInterface $translator,
|
||||
UserService $userService
|
||||
UserService $userService,
|
||||
ActivityService $activityService,
|
||||
): Response
|
||||
{
|
||||
// Init user
|
||||
|
|
@ -294,12 +259,31 @@ class UserController extends AbstractController
|
|||
}
|
||||
|
||||
// Update
|
||||
$userService->toggleUserStar(
|
||||
$value = $userService->toggleUserStar(
|
||||
$user->getId(),
|
||||
$userTarget->getId(),
|
||||
time()
|
||||
);
|
||||
|
||||
// Add activity event
|
||||
if ($value)
|
||||
{
|
||||
$activityService->addEventUserStarAdd(
|
||||
$user->getId(),
|
||||
time(),
|
||||
$userTarget->getId()
|
||||
);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
$activityService->addEventUserStarDelete(
|
||||
$user->getId(),
|
||||
time(),
|
||||
$userTarget->getId()
|
||||
);
|
||||
}
|
||||
|
||||
// Redirect to info article created
|
||||
return $this->redirectToRoute(
|
||||
'user_info',
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue