Skip to content

Commit

Permalink
fix(search): Hide search providers when not allowed to use Talk
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>

[skip ci]
  • Loading branch information
nickvergessen authored and backportbot[bot] committed Feb 21, 2024
1 parent aecdfe8 commit 5f7e109
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 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 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
3 changes: 3 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 Down Expand Up @@ -55,6 +56,8 @@ public function __construct(
protected ITimeFactory $timeFactory,
protected IURLGenerator $url,
protected IL10N $l,
protected Config $talkConfig,
protected IUserSession $userSession,
) {
}

Expand Down

0 comments on commit 5f7e109

Please sign in to comment.