Skip to content

Commit

Permalink
fix(search): Only register search filter when allowed to use Talk
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 21, 2024
1 parent fd6e11f commit e95fc14
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 e95fc14

Please sign in to comment.