From 846ec37cd93938f0336dd1f1a1d7f9a30568b07a Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Tue, 28 Dec 2021 18:45:18 +0000 Subject: [PATCH] [COMPONENT][Notification] Add event to decide whether local actors should be bothered --- components/Notification/Notification.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/components/Notification/Notification.php b/components/Notification/Notification.php index 9f19507efc..62ddce6658 100644 --- a/components/Notification/Notification.php +++ b/components/Notification/Notification.php @@ -82,12 +82,14 @@ class Notification extends Component continue; } } - // TODO: use https://symfony.com/doc/current/notifier.html - DB::persist(Entity\Notification::create([ - 'activity_id' => $activity->getId(), - 'target_id' => $target->getId(), - 'reason' => $reason, - ])); + if (Event::handle('NewNotificationShould', [$activity, $target]) === Event::next) { + // TODO: use https://symfony.com/doc/current/notifier.html + DB::persist(Entity\Notification::create([ + 'activity_id' => $activity->getId(), + 'target_id' => $target->getId(), + 'reason' => $reason, + ])); + } } else { // We have no authority nor responsibility of notifying remote actors of a remote actor's doing if ($sender->getIsLocal()) {