From 4a96e222588104f647f911857e370b3ab692ea22 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Wed, 6 Sep 2017 16:09:29 +0200 Subject: don't keep result types hard coded Signed-off-by: Arthur Schiwon --- lib/private/Collaboration/Collaborators/RemotePlugin.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'lib/private/Collaboration/Collaborators/RemotePlugin.php') diff --git a/lib/private/Collaboration/Collaborators/RemotePlugin.php b/lib/private/Collaboration/Collaborators/RemotePlugin.php index ff075b8e42d..c97a951be7e 100644 --- a/lib/private/Collaboration/Collaborators/RemotePlugin.php +++ b/lib/private/Collaboration/Collaborators/RemotePlugin.php @@ -26,6 +26,7 @@ namespace OC\Collaboration\Collaborators; use OCP\Collaboration\Collaborators\ISearchPlugin; use OCP\Collaboration\Collaborators\ISearchResult; +use OCP\Collaboration\Collaborators\SearchResultType; use OCP\Contacts\IManager; use OCP\Federation\ICloudIdManager; use OCP\IConfig; @@ -51,6 +52,7 @@ class RemotePlugin implements ISearchPlugin { public function search($search, $limit, $offset, ISearchResult $searchResult) { $result = ['wide' => [], 'exact' => []]; + $resultType = new SearchResultType('remotes'); // Search in contacts //@todo Pagination missing @@ -74,7 +76,7 @@ class RemotePlugin implements ISearchPlugin { if (strtolower($contact['FN']) === $lowerSearch || strtolower($cloudId) === $lowerSearch) { if (strtolower($cloudId) === $lowerSearch) { - $searchResult->hasExactIdMatch('remotes'); + $searchResult->hasExactIdMatch($resultType); } $result['exact'][] = [ 'label' => $contact['FN'] . " ($cloudId)", @@ -102,7 +104,7 @@ class RemotePlugin implements ISearchPlugin { $result['wide'] = []; } - if (!$searchResult->hasExactIdMatch('remotes') && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { + if (!$searchResult->hasExactIdMatch($resultType) && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) { $result['exact'][] = [ 'label' => $search, 'value' => [ @@ -112,7 +114,7 @@ class RemotePlugin implements ISearchPlugin { ]; } - $searchResult->addResultSet('remotes', $result['wide'], $result['exact']); + $searchResult->addResultSet($resultType, $result['wide'], $result['exact']); return false; } -- cgit v1.2.3