Skip to content

Commit

Permalink
[NationalEvent] Update share url with referrer code (#11538)
Browse files Browse the repository at this point in the history
* [NationalEvent] Update share url with referrer code

* Adjust tests

---------

Co-authored-by: Rémi <[email protected]>
  • Loading branch information
Remg and Rémi authored Feb 28, 2025
1 parent 6dcc4ca commit d3b7deb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
4 changes: 2 additions & 2 deletions features/api/alerts.feature
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ Feature:
"title": "Venez nombreux !",
"description": "",
"cta_label": "Je réserve ma place",
"cta_url": "http://test.renaissance.code/connexion-avec-un-lien-magique?@string@&_target_path=%2Fgrand-rassemblement%2Fevent-national-1",
"cta_url": "http://test.renaissance.code/connexion-avec-un-lien-magique?@string@&_target_path=%2Fgrand-rassemblement%2Fevent-national-1%2F@string@",
"image_url": null,
"share_url": "http://inscription.besoindeurope.code/grand-rassemblement/event-national-1"
"share_url": "http://inscription.besoindeurope.code/grand-rassemblement/event-national-1/@string@"
},
{
"type": "election",
Expand Down
27 changes: 26 additions & 1 deletion src/JeMengage/Alert/Provider/MeetingProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\JeMengage\Alert\Alert;
use App\Repository\NationalEvent\EventInscriptionRepository;
use App\Repository\NationalEvent\NationalEventRepository;
use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Http\LoginLink\LoginLinkHandlerInterface;

Expand All @@ -16,6 +17,7 @@ public function __construct(
private readonly EventInscriptionRepository $eventInscriptionRepository,
private readonly LoginLinkHandlerInterface $loginLinkHandler,
private readonly UrlGeneratorInterface $urlGenerator,
private readonly Security $security,
) {
}

Expand All @@ -31,7 +33,23 @@ public function getAlerts(Adherent $adherent): array
$ctaLabel = 'Inscrit';
$ctaUrl = '';
$imageUrl = null;
$eventInscriptionUrl = $this->urlGenerator->generate('app_national_event_by_slug', ['slug' => $event->getSlug()], UrlGeneratorInterface::ABSOLUTE_URL);
$currentUser = $this->getCurrentUser();
$eventInscriptionUrl = $currentUser
? $this->urlGenerator->generate(
'app_national_event_by_slug_with_referrer',
[
'slug' => $event->getSlug(),
'referrerCode' => $currentUser->getPublicId(),
],
UrlGeneratorInterface::ABSOLUTE_URL
)
: $this->urlGenerator->generate(
'app_national_event_by_slug',
[
'slug' => $event->getSlug(),
],
UrlGeneratorInterface::ABSOLUTE_URL
);

if ($event->ogImage) {
$imageUrl = $this->urlGenerator->generate('asset_url', ['path' => $event->ogImage->getPath()], UrlGeneratorInterface::ABSOLUTE_URL);
Expand All @@ -52,4 +70,11 @@ public function getAlerts(Adherent $adherent): array

return $alerts;
}

private function getCurrentUser(): ?Adherent
{
$user = $this->security->getUser();

return $user instanceof Adherent ? $user : null;
}
}

0 comments on commit d3b7deb

Please sign in to comment.