Skip to content

Commit

Permalink
[Event] persist live view action
Browse files Browse the repository at this point in the history
  • Loading branch information
ottaviano committed Feb 10, 2025
1 parent c4e461c commit 2431e92
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/Controller/Renaissance/LiveStreamController.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use App\Entity\Adherent;
use App\Entity\Event\Event;
use App\Entity\LiveStream;
use App\History\UserActionHistoryHandler;
use App\OAuth\OAuthAuthenticator;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
Expand Down Expand Up @@ -32,7 +33,7 @@ public function liveStreamAction(LiveStream $liveStream, UserInterface $user): R
}

#[Route('/live-event/{slug}', name: 'app_live_event', methods: ['GET'])]
public function liveEventAction(Request $request, OAuthAuthenticator $authAuthenticator, Event $event): Response
public function liveEventAction(Request $request, UserActionHistoryHandler $userActionHistoryHandler, OAuthAuthenticator $authAuthenticator, Event $event): Response
{
if (!($user = $this->getUser()) instanceof Adherent) {
$newRequest = $request->duplicate([]);
Expand All @@ -48,6 +49,8 @@ public function liveEventAction(Request $request, OAuthAuthenticator $authAuthen
return $this->redirectToRoute('app_adhesion_index');
}

$userActionHistoryHandler->createLiveParticipation($user, $event);

return $this->render('renaissance/live_event.html.twig', [
'event' => $event,
]);
Expand Down
13 changes: 13 additions & 0 deletions src/History/UserActionHistoryHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use App\Entity\Adherent;
use App\Entity\Administrator;
use App\Entity\Event\Event;
use App\Entity\Geo\Zone;
use App\History\Command\UserActionHistoryCommand;
use Symfony\Bundle\SecurityBundle\Security;
Expand Down Expand Up @@ -128,6 +129,18 @@ public function createRoleRemove(Adherent $adherent, string $role, array $zones,
);
}

public function createLiveParticipation(Adherent $adherent, Event $event): void
{
$this->dispatch(
$adherent,
UserActionHistoryTypeEnum::LIVE_VIEW,
[
'event' => $event->getName(),
'event_id' => $event->getId(),
]
);
}

private function getImpersonator(): ?Administrator
{
$token = $this->security->getToken();
Expand Down
1 change: 1 addition & 0 deletions src/History/UserActionHistoryTypeEnum.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,5 @@ enum UserActionHistoryTypeEnum: string
case EMAIL_CHANGE_VALIDATE = 'email_change_validate';
case ROLE_ADD = 'role_add';
case ROLE_REMOVE = 'role_remove';
case LIVE_VIEW = 'live_view';
}

0 comments on commit 2431e92

Please sign in to comment.