Skip to content

Commit

Permalink
Merge pull request #1655 from nextcloud/backport/1650/stable27
Browse files Browse the repository at this point in the history
[stable27] fix(notifications): Don't trigger invite notifications for system groups
  • Loading branch information
kesselb authored Aug 1, 2024
2 parents da826be + 1fc6a7d commit 816f29a
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions lib/Listeners/Notifications/RequestingMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@
* Class RequestingMember
*
* @package OCA\Circles\Listeners\Notifications
*
* @template-implements IEventListener<RequestingCircleMemberEvent|AddingCircleMemberEvent|Event>
*/
class RequestingMember implements IEventListener {
use TNCLogger;
Expand All @@ -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);
}
}
}

0 comments on commit 816f29a

Please sign in to comment.