Skip to content

Commit

Permalink
Fix reports not triggering push notifications (#1249)
Browse files Browse the repository at this point in the history
Co-authored-by: Melroy van den Berg <[email protected]>
  • Loading branch information
BentiGorlich and melroy89 authored Nov 26, 2024
1 parent 6284d59 commit 60ce242
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/Service/Notification/ReportNotificationManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
) {
}

Expand Down Expand Up @@ -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));
}
}

Expand All @@ -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));
}
}
}

0 comments on commit 60ce242

Please sign in to comment.