Skip to content

Commit

Permalink
fix(notifications): Don't trigger invite notifications for system groups
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Jul 31, 2024
1 parent d9610a0 commit 3aa0c06
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions lib/Listeners/Notifications/RequestingMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,25 +36,34 @@
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;

/** @template-implements IEventListener<RequestingCircleMemberEvent|Event> */
/** @template-implements IEventListener<RequestingCircleMemberEvent|AddingCircleMemberEvent|Event> */
class RequestingMember implements IEventListener {
public function __construct(
private NotificationService $notificationService,
) {
}

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);
}
}
}

0 comments on commit 3aa0c06

Please sign in to comment.