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

fix(search): Only register search filter when allowed to use Talk #11615

Merged
merged 1 commit into from
Feb 21, 2024
Merged
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
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
Loading