Skip to content

Commit

Permalink
Merge pull request #1653 from nextcloud/backport/1650/stable29
Browse files Browse the repository at this point in the history
[stable29] fix(notifications): Don't trigger invite notifications for system groups
  • Loading branch information
AndyScherzinger authored Aug 1, 2024
2 parents d9610a0 + 3aa0c06 commit d40baae
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 d40baae

Please sign in to comment.