From 96acce9907c582ce199deef2324d666b8e81dcad 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 [skip ci] --- .../Notifications/RequestingMember.php | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/lib/Listeners/Notifications/RequestingMember.php b/lib/Listeners/Notifications/RequestingMember.php index 44635c132..d8bb28887 100644 --- a/lib/Listeners/Notifications/RequestingMember.php +++ b/lib/Listeners/Notifications/RequestingMember.php @@ -71,18 +71,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); + } + } }