Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable29] fix(notifications): Don't trigger invite notifications for system groups #1653

Merged
merged 1 commit into from
Aug 1, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
}
}
Loading