Skip to content

Commit c937eed

Browse files
authored
Merge pull request #56844 from nextcloud/backport/56501/stable31
2 parents b0f6f2e + e7ce707 commit c937eed

File tree

2 files changed

+37
-10
lines changed

2 files changed

+37
-10
lines changed

lib/private/Collaboration/Collaborators/LookupPlugin.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
namespace OC\Collaboration\Collaborators;
77

8+
use OCA\Federation\TrustedServers;
89
use OCP\Collaboration\Collaborators\ISearchPlugin;
910
use OCP\Collaboration\Collaborators\ISearchResult;
1011
use OCP\Collaboration\Collaborators\SearchResultType;
@@ -25,6 +26,7 @@ public function __construct(
2526
IUserSession $userSession,
2627
private ICloudIdManager $cloudIdManager,
2728
private LoggerInterface $logger,
29+
private ?TrustedServers $trustedServers,
2830
) {
2931
$currentUserCloudId = $userSession->getUser()->getCloudId();
3032
$this->currentUserRemote = $cloudIdManager->resolveCloudId($currentUserCloudId)->getRemote();
@@ -81,6 +83,8 @@ public function search($search, $limit, $offset, ISearchResult $searchResult): b
8183
'shareType' => IShare::TYPE_REMOTE,
8284
'globalScale' => $isGlobalScaleEnabled,
8385
'shareWith' => $lookup['federationId'],
86+
'server' => $remote,
87+
'isTrustedServer' => $this->trustedServers?->isTrustedServer($remote) ?? false,
8488
],
8589
'extra' => $lookup,
8690
];

tests/lib/Collaboration/Collaborators/LookupPluginTest.php

Lines changed: 33 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ protected function setUp(): void {
5656
if ($cloudId === '[email protected]') {
5757
return new CloudId('[email protected]', 'user', 'myNextcloud.net');
5858
}
59+
if (str_contains($cloudId, '@enceladus.moon')) {
60+
[$user, $remote] = explode('@', $cloudId, 2);
61+
return new CloudId($cloudId, $user, $remote);
62+
}
5963
return new CloudId('[email protected]', 'user', 'someNextcloud.net');
6064
});
6165

@@ -65,7 +69,8 @@ protected function setUp(): void {
6569
$this->clientService,
6670
$this->userSession,
6771
$this->cloudIdManager,
68-
$this->logger
72+
$this->logger,
73+
null
6974
);
7075
}
7176

@@ -300,7 +305,9 @@ public function dataSearchEnableDisableLookupServer() {
300305
'value' => [
301306
'shareType' => IShare::TYPE_REMOTE,
302307
'globalScale' => true,
303-
'shareWith' => $fedIDs[0]
308+
'shareWith' => $fedIDs[0],
309+
'server' => 'enceladus.moon',
310+
'isTrustedServer' => false,
304311
],
305312
'extra' => ['federationId' => $fedIDs[0]],
306313
],
@@ -309,7 +316,9 @@ public function dataSearchEnableDisableLookupServer() {
309316
'value' => [
310317
'shareType' => IShare::TYPE_REMOTE,
311318
'globalScale' => true,
312-
'shareWith' => $fedIDs[1]
319+
'shareWith' => $fedIDs[1],
320+
'server' => 'enceladus.moon',
321+
'isTrustedServer' => false,
313322
],
314323
'extra' => ['federationId' => $fedIDs[1]],
315324
],
@@ -318,7 +327,9 @@ public function dataSearchEnableDisableLookupServer() {
318327
'value' => [
319328
'shareType' => IShare::TYPE_REMOTE,
320329
'globalScale' => true,
321-
'shareWith' => $fedIDs[2]
330+
'shareWith' => $fedIDs[2],
331+
'server' => 'enceladus.moon',
332+
'isTrustedServer' => false,
322333
],
323334
'extra' => ['federationId' => $fedIDs[2]],
324335
],
@@ -342,7 +353,9 @@ public function dataSearchEnableDisableLookupServer() {
342353
'value' => [
343354
'shareType' => IShare::TYPE_REMOTE,
344355
'globalScale' => true,
345-
'shareWith' => $fedIDs[0]
356+
'shareWith' => $fedIDs[0],
357+
'server' => 'enceladus.moon',
358+
'isTrustedServer' => false,
346359
],
347360
'extra' => ['federationId' => $fedIDs[0]],
348361
],
@@ -351,7 +364,9 @@ public function dataSearchEnableDisableLookupServer() {
351364
'value' => [
352365
'shareType' => IShare::TYPE_REMOTE,
353366
'globalScale' => true,
354-
'shareWith' => $fedIDs[1]
367+
'shareWith' => $fedIDs[1],
368+
'server' => 'enceladus.moon',
369+
'isTrustedServer' => false,
355370
],
356371
'extra' => ['federationId' => $fedIDs[1]],
357372
],
@@ -360,7 +375,9 @@ public function dataSearchEnableDisableLookupServer() {
360375
'value' => [
361376
'shareType' => IShare::TYPE_REMOTE,
362377
'globalScale' => true,
363-
'shareWith' => $fedIDs[2]
378+
'shareWith' => $fedIDs[2],
379+
'server' => 'enceladus.moon',
380+
'isTrustedServer' => false,
364381
],
365382
'extra' => ['federationId' => $fedIDs[2]],
366383
],
@@ -474,7 +491,9 @@ public function searchDataProvider() {
474491
'value' => [
475492
'shareType' => IShare::TYPE_REMOTE,
476493
'globalScale' => true,
477-
'shareWith' => $fedIDs[0]
494+
'shareWith' => $fedIDs[0],
495+
'server' => 'enceladus.moon',
496+
'isTrustedServer' => false,
478497
],
479498
'extra' => ['federationId' => $fedIDs[0]],
480499
],
@@ -483,7 +502,9 @@ public function searchDataProvider() {
483502
'value' => [
484503
'shareType' => IShare::TYPE_REMOTE,
485504
'globalScale' => true,
486-
'shareWith' => $fedIDs[1]
505+
'shareWith' => $fedIDs[1],
506+
'server' => 'enceladus.moon',
507+
'isTrustedServer' => false,
487508
],
488509
'extra' => ['federationId' => $fedIDs[1]],
489510
],
@@ -492,7 +513,9 @@ public function searchDataProvider() {
492513
'value' => [
493514
'shareType' => IShare::TYPE_REMOTE,
494515
'globalScale' => true,
495-
'shareWith' => $fedIDs[2]
516+
'shareWith' => $fedIDs[2],
517+
'server' => 'enceladus.moon',
518+
'isTrustedServer' => false,
496519
],
497520
'extra' => ['federationId' => $fedIDs[2]],
498521
],

0 commit comments

Comments
 (0)