From 60ce24204baa7fbd0021f6d91cb03913773df258 Mon Sep 17 00:00:00 2001 From: BentiGorlich Date: Tue, 26 Nov 2024 14:54:02 +0100 Subject: [PATCH] Fix reports not triggering push notifications (#1249) Co-authored-by: Melroy van den Berg --- 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)); } } }