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

[stable28] fix(search): Hide search providers when not allowed to use Talk #11623

Merged
merged 1 commit into from
Feb 22, 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
11 changes: 10 additions & 1 deletion lib/Search/ConversationSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
namespace OCA\Talk\Search;

use OCA\Talk\AppInfo\Application;
use OCA\Talk\Config;
use OCA\Talk\Manager;
use OCA\Talk\Room;
use OCA\Talk\Service\AvatarService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Search\IProvider;
use OCP\Search\ISearchQuery;
use OCP\Search\SearchResult;
Expand All @@ -44,6 +46,8 @@ public function __construct(
protected Manager $manager,
protected IURLGenerator $url,
protected IL10N $l,
protected Config $talkConfig,
protected IUserSession $userSession,
) {
}

Expand All @@ -64,7 +68,12 @@ public function getName(): string {
/**
* @inheritDoc
*/
public function getOrder(string $route, array $routeParameters): int {
public function getOrder(string $route, array $routeParameters): ?int {
$currentUser = $this->userSession->getUser();
if ($currentUser && $this->talkConfig->isDisabledForUser($currentUser)) {
return null;
}

if (strpos($route, Application::APP_ID . '.') === 0) {
// Active app, prefer Talk results
return -1;
Expand Down
5 changes: 5 additions & 0 deletions lib/Search/CurrentMessageSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ public function getName(): string {
* @inheritDoc
*/
public function getOrder(string $route, array $routeParameters): ?int {
$currentUser = $this->userSession->getUser();
if ($currentUser && $this->talkConfig->isDisabledForUser($currentUser)) {
return null;
}

if ($route === 'spreed.Page.showCall') {
// In conversation, prefer this search results
return -3;
Expand Down
9 changes: 9 additions & 0 deletions lib/Search/MessageSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use OCA\Talk\AppInfo\Application;
use OCA\Talk\Chat\ChatManager;
use OCA\Talk\Chat\MessageParser;
use OCA\Talk\Config;
use OCA\Talk\Exceptions\ParticipantNotFoundException;
use OCA\Talk\Exceptions\UnauthorizedException;
use OCA\Talk\Manager as RoomManager;
Expand All @@ -38,6 +39,7 @@
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
use OCP\IUserSession;
use OCP\Search\IFilter;
use OCP\Search\IFilteringProvider;
use OCP\Search\IProvider;
Expand All @@ -55,6 +57,8 @@ public function __construct(
protected ITimeFactory $timeFactory,
protected IURLGenerator $url,
protected IL10N $l,
protected Config $talkConfig,
protected IUserSession $userSession,
) {
}

Expand All @@ -76,6 +80,11 @@ public function getName(): string {
* @inheritDoc
*/
public function getOrder(string $route, array $routeParameters): ?int {
$currentUser = $this->userSession->getUser();
if ($currentUser && $this->talkConfig->isDisabledForUser($currentUser)) {
return null;
}

if (strpos($route, Application::APP_ID . '.') === 0) {
// Active app, prefer Talk results
return -2;
Expand Down
Loading