[COMPONENT][Notification] Additional check to avoid unnecessary notifications

This commit is contained in:
Diogo Peralta Cordeiro 2022-02-11 13:44:32 +00:00
parent 17733f32d6
commit 6b4fa8c303
No known key found for this signature in database
GPG Key ID: 18D2D35001FBFAB0

View File

@ -79,6 +79,11 @@ class Notification extends Component
continue; continue;
} }
if (Event::handle('NewNotificationShould', [$activity, $target]) === Event::next) { 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 // TODO: use https://symfony.com/doc/current/notifier.html
// XXX: Unideal as in failures the rollback will leave behind a false notification, // XXX: Unideal as in failures the rollback will leave behind a false notification,
// but most notifications (all) require flushing the objects first // but most notifications (all) require flushing the objects first