diff --git a/lib/private/Collaboration/Collaborators/LookupPlugin.php b/lib/private/Collaboration/Collaborators/LookupPlugin.php index 2c8dc8454582f..10ce4dedb7ab9 100644 --- a/lib/private/Collaboration/Collaborators/LookupPlugin.php +++ b/lib/private/Collaboration/Collaborators/LookupPlugin.php @@ -5,6 +5,7 @@ */ namespace OC\Collaboration\Collaborators; +use OCA\Federation\TrustedServers; use OCP\Collaboration\Collaborators\ISearchPlugin; use OCP\Collaboration\Collaborators\ISearchResult; use OCP\Collaboration\Collaborators\SearchResultType; @@ -25,6 +26,7 @@ public function __construct( IUserSession $userSession, private ICloudIdManager $cloudIdManager, private LoggerInterface $logger, + private ?TrustedServers $trustedServers, ) { $currentUserCloudId = $userSession->getUser()->getCloudId(); $this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote(); @@ -81,6 +83,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => $isGlobalScaleEnabled, 'shareWith' => $lookup['federationId'], + 'server' => $remote, + 'isTrustedServer' => $this->trustedServers?->isTrustedServer($remote) ?? false, ], 'extra' => $lookup, ]; diff --git a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php index 7ff01831e1823..31e73a4303363 100644 --- a/tests/lib/Collaboration/Collaborators/LookupPluginTest.php +++ b/tests/lib/Collaboration/Collaborators/LookupPluginTest.php @@ -56,6 +56,10 @@ protected function setUp(): void { if ($cloudId === 'user@myNextcloud.net') { return new CloudId('user@myNextcloud.net', 'user', 'myNextcloud.net'); } + if (str_contains($cloudId, '@enceladus.moon')) { + [$user, $remote] = explode('@', $cloudId, 2); + return new CloudId($cloudId, $user, $remote); + } return new CloudId('user@someNextcloud.net', 'user', 'someNextcloud.net'); }); @@ -65,7 +69,8 @@ protected function setUp(): void { $this->clientService, $this->userSession, $this->cloudIdManager, - $this->logger + $this->logger, + null ); } @@ -300,7 +305,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[0] + 'shareWith' => $fedIDs[0], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[0]], ], @@ -309,7 +316,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[1] + 'shareWith' => $fedIDs[1], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[1]], ], @@ -318,7 +327,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[2] + 'shareWith' => $fedIDs[2], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[2]], ], @@ -342,7 +353,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[0] + 'shareWith' => $fedIDs[0], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[0]], ], @@ -351,7 +364,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[1] + 'shareWith' => $fedIDs[1], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[1]], ], @@ -360,7 +375,9 @@ public function dataSearchEnableDisableLookupServer() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[2] + 'shareWith' => $fedIDs[2], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[2]], ], @@ -474,7 +491,9 @@ public function searchDataProvider() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[0] + 'shareWith' => $fedIDs[0], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[0]], ], @@ -483,7 +502,9 @@ public function searchDataProvider() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[1] + 'shareWith' => $fedIDs[1], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[1]], ], @@ -492,7 +513,9 @@ public function searchDataProvider() { 'value' => [ 'shareType' => IShare::TYPE_REMOTE, 'globalScale' => true, - 'shareWith' => $fedIDs[2] + 'shareWith' => $fedIDs[2], + 'server' => 'enceladus.moon', + 'isTrustedServer' => false, ], 'extra' => ['federationId' => $fedIDs[2]], ],