diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2020-08-03 12:54:37 +0200 |
---|---|---|
committer | npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com> | 2020-08-03 11:26:03 +0000 |
commit | 1a1b3e20e470a945dd9f5fab1d99174b10cbb141 (patch) | |
tree | aacff8872bcfd47685e9a9fb3e5e3a423e498f59 /apps/comments | |
parent | 4987fe9a51f0b889d2b99428c967014d95bb13ae (diff) | |
download | nextcloud-server-1a1b3e20e470a945dd9f5fab1d99174b10cbb141.tar.gz nextcloud-server-1a1b3e20e470a945dd9f5fab1d99174b10cbb141.zip |
Fix unified search
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Signed-off-by: npmbuildbot[bot] <npmbuildbot[bot]@users.noreply.github.com>
Diffstat (limited to 'apps/comments')
-rw-r--r-- | apps/comments/lib/Search/Provider.php | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/apps/comments/lib/Search/Provider.php b/apps/comments/lib/Search/Provider.php index 0c0561c988c..2f3575d9c84 100644 --- a/apps/comments/lib/Search/Provider.php +++ b/apps/comments/lib/Search/Provider.php @@ -28,6 +28,7 @@ namespace OCA\Comments\Search; use OCP\IL10N; use OCP\IURLGenerator; use OCP\IUser; +use OCP\IUserManager; use OCP\Search\IProvider; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; @@ -36,6 +37,9 @@ use function pathinfo; class Provider implements IProvider { + /** @var IUserManager */ + private $userManager; + /** @var IL10N */ private $l10n; @@ -45,9 +49,11 @@ class Provider implements IProvider { /** @var LegacyProvider */ private $legacyProvider; - public function __construct(IL10N $l10n, + public function __construct(IUserManager $userManager, + IL10N $l10n, IURLGenerator $urlGenerator, LegacyProvider $legacyProvider) { + $this->userManager = $userManager; $this->l10n = $l10n; $this->urlGenerator = $urlGenerator; $this->legacyProvider = $legacyProvider; @@ -57,23 +63,30 @@ class Provider implements IProvider { return 'comments'; } + public function getName(): string { + return $this->l10n->t('Comments'); + } + public function search(IUser $user, ISearchQuery $query): SearchResult { return SearchResult::complete( $this->l10n->t('Comments'), array_map(function (Result $result) { $path = $result->path; $pathInfo = pathinfo($path); + $isUser = $this->userManager->userExists($result->authorId); + $avatarUrl = $isUser + ? $this->urlGenerator->linkToRoute('core.avatar.getAvatar', ['userId' => $result->authorId, 'size' => 42]) + : $this->urlGenerator->linkToRoute('core.GuestAvatar.getAvatar', ['guestName' => $result->authorId, 'size' => 42]); return new CommentsSearchResultEntry( - $this->urlGenerator->linkToRoute('core.Preview.getPreviewByFileId', ['x' => 32, 'y' => 32, 'fileId' => $result->id]), + $avatarUrl, $result->name, $path, - $this->urlGenerator->linkToRoute( - 'files.view.index', - [ - 'dir' => $pathInfo['dirname'], - 'scrollto' => $pathInfo['basename'], - ] - ) + $this->urlGenerator->linkToRoute('files.view.index',[ + 'dir' => $pathInfo['dirname'], + 'scrollto' => $pathInfo['basename'], + ]), + '', + true ); }, $this->legacyProvider->search($query->getTerm())) ); |