From dd54ee65bfc9c5be27291e49ed4d8b3b064ac673 Mon Sep 17 00:00:00 2001 From: BentiGorlich Date: Tue, 26 Nov 2024 10:46:36 +0100 Subject: [PATCH] Fix reports not triggering push notifications Push notifications are sent by listening to the `NotificationCreatedEvent` which was not triggered by report notifications --- src/Service/Notification/ReportNotificationManager.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/Service/Notification/ReportNotificationManager.php b/src/Service/Notification/ReportNotificationManager.php index 7f39fb9b7..6a0ec2552 100644 --- a/src/Service/Notification/ReportNotificationManager.php +++ b/src/Service/Notification/ReportNotificationManager.php @@ -8,14 +8,17 @@ use App\Entity\Report; use App\Entity\ReportApprovedNotification; use App\Entity\ReportCreatedNotification; +use App\Event\NotificationCreatedEvent; use App\Repository\UserRepository; use Doctrine\ORM\EntityManagerInterface; +use Symfony\Component\EventDispatcher\EventDispatcherInterface; class ReportNotificationManager { public function __construct( private readonly EntityManagerInterface $entityManager, private readonly UserRepository $userRepository, + private readonly EventDispatcherInterface $dispatcher, ) { } @@ -46,6 +49,7 @@ public function sendReportCreatedNotification(Report $report): void $map[$receiver->getId()] = true; $n = new ReportCreatedNotification($receiver, $report); $this->entityManager->persist($n); + $this->dispatcher->dispatch(new NotificationCreatedEvent($n)); } } @@ -62,6 +66,7 @@ public function sendReportApprovedNotification(Report $report): void $notification = new ReportApprovedNotification($report->reported, $report); $this->entityManager->persist($notification); $this->entityManager->flush(); + $this->dispatcher->dispatch(new NotificationCreatedEvent($notification)); } } }