diff --git a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php index afb6eba19..91bea3197 100644 --- a/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php +++ b/src/Bundle/ChillMainBundle/Notification/NotificationPresence.php @@ -36,11 +36,13 @@ class NotificationPresence */ public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId): array { - if ($this->security->getUser() instanceof User) { - return $this->notificationRepository->findNotificationAsAddresseeByRelatedEntityAndUser( + $user = $this->security->getUser(); + + if ($user instanceof User) { + return $this->notificationRepository->findNotificationByRelatedEntityAndUserAssociated( $relatedEntityClass, $relatedEntityId, - $this->security->getUser() + $user ); } diff --git a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php index ce9e3b9e9..e2452dced 100644 --- a/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php +++ b/src/Bundle/ChillMainBundle/Repository/NotificationRepository.php @@ -148,7 +148,7 @@ final class NotificationRepository implements ObjectRepository /** * @return array|Notification[] */ - public function findNotificationAsAddresseeByRelatedEntityAndUser(string $relatedEntityClass, int $relatedEntityId, User $user): array + public function findNotificationByRelatedEntityAndUserAssociated(string $relatedEntityClass, int $relatedEntityId, User $user): array { $qb = $this->repository->createQueryBuilder('n'); @@ -156,7 +156,12 @@ final class NotificationRepository implements ObjectRepository ->select('n') ->where($qb->expr()->eq('n.relatedEntityClass', ':relatedEntityClass')) ->andWhere($qb->expr()->eq('n.relatedEntityId', ':relatedEntityId')) - ->andWhere($qb->expr()->isMemberOf(':user', 'n.addressees')) + ->andWhere( + $qb->expr()->orX( + $qb->expr()->isMemberOf(':user', 'n.addressees'), + $qb->expr()->eq('n.sender', ':user') + ) + ) ->setParameter('relatedEntityClass', $relatedEntityClass) ->setParameter('relatedEntityId', $relatedEntityId) ->setParameter('user', $user); diff --git a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig index 5e5d1dba8..b57aab322 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Notification/extension_list_notifications_for.html.twig @@ -2,7 +2,11 @@ {% for notification in notifications %}