Skip to content

Commit

Permalink
feat: dismiss notification when accepting an invitation
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Kesselberg <mail@danielkesselberg.de>
  • Loading branch information
kesselb authored and backportbot[bot] committed Jul 30, 2024
1 parent 6bc5f8d commit 7cecde2
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ public function register(IRegistrationContext $context): void {
$context->registerEventListener(LoadAdditionalScriptsEvent::class, ListenerFilesLoadScripts::class);
$context->registerEventListener(PreparingCircleMemberEvent::class, ListenerFilesPreparingMemberSendMail::class);
$context->registerEventListener(AddingCircleMemberEvent::class, ListenerFilesAddingMemberSendMail::class);
$context->registerEventListener(AddingCircleMemberEvent::class, ListenerNotificationsRequestingMember::class);
$context->registerEventListener(CircleMemberAddedEvent::class, ListenerFilesMemberAddedSendMail::class);
$context->registerEventListener(PreparingFileShareEvent::class, ListenerFilesPreparingShareSendMail::class);
$context->registerEventListener(CreatingFileShareEvent::class, ListenerFilesCreatingShareSendMail::class);
Expand Down
6 changes: 5 additions & 1 deletion lib/Listeners/Notifications/RequestingMember.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,10 @@

namespace OCA\Circles\Listeners\Notifications;

use OCA\Circles\Events\AddingCircleMemberEvent;
use OCA\Circles\Events\CircleGenericEvent;
use OCA\Circles\Events\RequestingCircleMemberEvent;
use OCA\Circles\Model\Circle;
use OCA\Circles\Service\NotificationService;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
Expand All @@ -42,13 +44,15 @@ public function __construct(
}

public function handle(Event $event): void {
if (!$event instanceof RequestingCircleMemberEvent) {
if (!$event instanceof RequestingCircleMemberEvent && !$event instanceof AddingCircleMemberEvent) {
return;
}

$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);
}
Expand Down
14 changes: 14 additions & 0 deletions lib/Service/NotificationService.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,4 +228,18 @@ private function linkToOCS(string $route, array $params = []): string {

return parse_url($absolute, PHP_URL_PATH);
}

public function markInvitationAsProcessed(Member $member): void {
if ($member->getUserType() !== Member::TYPE_USER || !$member->isLocal()) {
return;
}

$notification = $this->notificationManager->createNotification();
$notification->setApp('circles')
->setUser($member->getUserId())
->setObject('member', $member->getId())
->setSubject('invitation');

$this->notificationManager->markProcessed($notification);
}
}

0 comments on commit 7cecde2

Please sign in to comment.