From 1fc6a7d1301f3967b8c8c5f7cd9e442b16504967 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 31 Jul 2024 10:46:19 +0200 Subject: [PATCH] fix(notifications): Don't trigger invite notifications for system groups Signed-off-by: Joas Schilling --- .../Notifications/RequestingMember.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/lib/Listeners/Notifications/RequestingMember.php b/lib/Listeners/Notifications/RequestingMember.php index 44635c132..111f7618c 100644 --- a/lib/Listeners/Notifications/RequestingMember.php +++ b/lib/Listeners/Notifications/RequestingMember.php @@ -46,6 +46,8 @@ * Class RequestingMember * * @package OCA\Circles\Listeners\Notifications + * + * @template-implements IEventListener */ class RequestingMember implements IEventListener { use TNCLogger; @@ -71,18 +73,27 @@ public function __construct(NotificationService $notificationService) { * @throws RequestBuilderException */ public function handle(Event $event): void { - if (!$event instanceof RequestingCircleMemberEvent && !$event instanceof AddingCircleMemberEvent) { - return; + if ($event instanceof RequestingCircleMemberEvent) { + $this->handleRequestingCircleMemberEvent($event); + } elseif ($event instanceof AddingCircleMemberEvent) { + $this->handleAddingCircleMemberEvent($event); } + } + public function handleRequestingCircleMemberEvent(RequestingCircleMemberEvent $event): void { $member = $event->getMember(); if ($event->getType() === CircleGenericEvent::REQUESTED) { $this->notificationService->notificationRequested($member); - } elseif ($event->getType() === CircleGenericEvent::JOINED && $event->getCircle()->isConfig(Circle::CFG_INVITE)) { - $this->notificationService->markInvitationAsProcessed($member); } else { $this->notificationService->notificationInvited($member); } } + + public function handleAddingCircleMemberEvent(AddingCircleMemberEvent $event): void { + if ($event->getType() === CircleGenericEvent::JOINED && $event->getCircle()->isConfig(Circle::CFG_INVITE)) { + $member = $event->getMember(); + $this->notificationService->markInvitationAsProcessed($member); + } + } }