From 6b4fa8c3038fbb773df8987ac6490e1473f52ac7 Mon Sep 17 00:00:00 2001 From: Diogo Peralta Cordeiro Date: Fri, 11 Feb 2022 13:44:32 +0000 Subject: [PATCH] [COMPONENT][Notification] Additional check to avoid unnecessary notifications --- components/Notification/Notification.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/Notification/Notification.php b/components/Notification/Notification.php index 84179130b2..daff732ebe 100644 --- a/components/Notification/Notification.php +++ b/components/Notification/Notification.php @@ -79,6 +79,11 @@ class Notification extends Component continue; } if (Event::handle('NewNotificationShould', [$activity, $target]) === Event::next) { + if ($sender->getId() === $target->getId() + || $activity->getActorId() === $target->getId()) { + // The target already knows about this, no need to bother with a notification + continue; + } // TODO: use https://symfony.com/doc/current/notifier.html // XXX: Unideal as in failures the rollback will leave behind a false notification, // but most notifications (all) require flushing the objects first