Skip to content

Commit

Permalink
Merge pull request #11615 from nextcloud/bugfix/noid/only-register-fi…
Browse files Browse the repository at this point in the history
…lter-when-allowed

fix(search): Only register search filter when allowed to use Talk
  • Loading branch information
nickvergessen authored Feb 21, 2024
2 parents ec442d8 + e95fc14 commit 981e57b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions lib/Search/UnifiedSearchFilterPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
/**
* @copyright Copyright (c) 2024 Fon E. Noel NFEBE <me@nfebe.com>
*
* @author Fon E. Noel NFEBE <me@nfebe.com>
* @author Joas Schilling <coding@schilljs.com>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
Expand All @@ -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;

/**
Expand All @@ -35,7 +39,8 @@
class UnifiedSearchFilterPlugin implements IEventListener {

public function __construct(
private IRequest $request,
protected Config $talkConfig,
protected IUserSession $userSession,
) {
}

Expand All @@ -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;
}

Expand Down

0 comments on commit 981e57b

Please sign in to comment.