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

[stable27] feat: dismiss notification when accepting an invitation #1645

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ public function register(IRegistrationContext $context): void {
AddingCircleMemberEvent::class,
ListenerFilesAddingMemberSendMail::class
);
$context->registerEventListener(AddingCircleMemberEvent::class, ListenerNotificationsRequestingMember::class);
$context->registerEventListener(
CircleMemberAddedEvent::class,
ListenerFilesMemberAddedSendMail::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 @@ -31,6 +31,8 @@

namespace OCA\Circles\Listeners\Notifications;

use OCA\Circles\Events\AddingCircleMemberEvent;
use OCA\Circles\Model\Circle;
use OCA\Circles\Tools\Traits\TNCLogger;
use OCA\Circles\AppInfo\Application;
use OCA\Circles\Events\CircleGenericEvent;
Expand Down Expand Up @@ -69,14 +71,16 @@ public function __construct(NotificationService $notificationService) {
* @throws RequestBuilderException
*/
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);
}
}
Loading