diff --git a/lib/Search/UnifiedSearchFilterPlugin.php b/lib/Search/UnifiedSearchFilterPlugin.php index 920942e699c..dc4fdbc58fb 100644 --- a/lib/Search/UnifiedSearchFilterPlugin.php +++ b/lib/Search/UnifiedSearchFilterPlugin.php @@ -4,6 +4,9 @@ /** * @copyright Copyright (c) 2024 Fon E. Noel NFEBE * + * @author Fon E. Noel NFEBE + * @author Joas Schilling + * * @license GNU AGPL version 3 or any later version * * This program is free software: you can redistribute it and/or modify @@ -23,10 +26,11 @@ namespace OCA\Talk\Search; +use OCA\Talk\Config; use OCP\AppFramework\Http\Events\BeforeTemplateRenderedEvent; use OCP\EventDispatcher\Event; use OCP\EventDispatcher\IEventListener; -use OCP\IRequest; +use OCP\IUserSession; use OCP\Util; /** @@ -35,7 +39,8 @@ class UnifiedSearchFilterPlugin implements IEventListener { public function __construct( - private IRequest $request, + protected Config $talkConfig, + protected IUserSession $userSession, ) { } @@ -44,7 +49,8 @@ public function handle(Event $event): void { return; } - if (!$event->isLoggedIn()) { + $currentUser = $this->userSession->getUser(); + if ($currentUser === null || $this->talkConfig->isDisabledForUser($currentUser)) { return; }