]> source.dussan.org Git - nextcloud-server.git/commitdiff
Extend data returned when searching remote shares
authorJohn Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Thu, 23 May 2019 15:03:04 +0000 (17:03 +0200)
committerDaniel Calviño Sánchez <danxuliu@gmail.com>
Tue, 29 Oct 2019 11:55:59 +0000 (12:55 +0100)
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
build/integration/sharees_features/sharees.feature
build/integration/sharees_features/sharees_provisioningapiv2.feature
lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php
lib/private/Collaboration/Collaborators/RemotePlugin.php
tests/lib/Collaboration/Collaborators/RemotePluginTest.php

index 58570cfc5f19f359cb593e3d937b3da17d1402a1..5a6291d1e2f73120c7b0540bf39dc394abe33d24 100644 (file)
@@ -206,7 +206,7 @@ Feature: sharees
     Then "exact groups" sharees returned is empty
     Then "groups" sharees returned is empty
     Then "exact remotes" sharees returned are
-      | test@localhost | 6 | test@localhost |
+      | test (localhost) | 6 | test@localhost |
     Then "remotes" sharees returned is empty
 
   Scenario: Remote sharee for calendars not allowed
index 37ab896ee2887d6feeea2cb92d59fe6bdcee1ec5..6f2b8df8e0e7049690d50f4d95291beb380cafb6 100644 (file)
@@ -206,7 +206,7 @@ Feature: sharees_provisioningapiv2
     Then "exact groups" sharees returned is empty
     Then "groups" sharees returned is empty
     Then "exact remotes" sharees returned are
-      | test@localhost | 6 | test@localhost |
+      | test (localhost) | 6 | test@localhost |
     Then "remotes" sharees returned is empty
 
   Scenario: Remote sharee for calendars not allowed
index 6e0979fe418b03149b2792cb3c8d812c8a07ac1b..d9e1f2fd49af21fafcf43d34a85672a68599cec5 100644 (file)
@@ -57,11 +57,15 @@ class RemoteGroupPlugin implements ISearchPlugin {
                $resultType = new SearchResultType('remote_groups');
 
                if ($this->enabled && $this->cloudIdManager->isValidCloudId($search) && $offset === 0) {
+                       list($remoteGroup, $serverUrl) = $this->splitGroupRemote($search);
                        $result['exact'][] = [
-                               'label' => $search,
+                               'label' => $remoteGroup . " ($serverUrl)",
+                               'guid' => $remoteGroup,
+                               'name' => $remoteGroup,
                                'value' => [
                                        'shareType' => Share::SHARE_TYPE_REMOTE_GROUP,
                                        'shareWith' => $search,
+                                       'server' => $serverUrl,
                                ],
                        ];
                }
@@ -71,4 +75,20 @@ class RemoteGroupPlugin implements ISearchPlugin {
                return true;
        }
 
+       /**
+        * split group and remote from federated cloud id
+        *
+        * @param string $address federated share address
+        * @return array [user, remoteURL]
+        * @throws \InvalidArgumentException
+        */
+       public function splitGroupRemote($address) {
+               try {
+                       $cloudId = $this->cloudIdManager->resolveCloudId($address);
+                       return [$cloudId->getUser(), $cloudId->getRemote()];
+               } catch (\InvalidArgumentException $e) {
+                       throw new \InvalidArgumentException('Invalid Federated Cloud ID', 0, $e);
+               }
+       }
+
 }
index d877346b1558a2fe3890ec257262998984d74b1f..fd14e7e03be8d49523ebb7735a82a34babf2e9be 100644 (file)
@@ -152,10 +152,13 @@ class RemotePlugin implements ISearchPlugin {
                                $localUser = $this->userManager->get($remoteUser);
                                if ($localUser === null || $search !== $localUser->getCloudId()) {
                                        $result['exact'][] = [
-                                               'label' => $search,
+                                               'label' => $remoteUser . " ($serverUrl)",
+                                               'uuid' => $remoteUser,
+                                               'name' => $remoteUser,
                                                'value' => [
                                                        'shareType' => Share::SHARE_TYPE_REMOTE,
                                                        'shareWith' => $search,
+                                                       'server' => $serverUrl,
                                                ],
                                        ];
                                }
index aff681857678b42547f3a59e10496eba9b363a23..560e72a984d880ca32557307232d6453f615b4f2 100644 (file)
@@ -152,7 +152,7 @@ class RemotePluginTest extends TestCase {
                                'test@remote',
                                [],
                                true,
-                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]],
+                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
                                false,
                                true,
                        ],
@@ -160,7 +160,7 @@ class RemotePluginTest extends TestCase {
                                'test@remote',
                                [],
                                false,
-                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]],
+                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
                                false,
                                true,
                        ],
@@ -238,7 +238,7 @@ class RemotePluginTest extends TestCase {
                                        ],
                                ],
                                true,
-                               ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]],
+                               ['remotes' => [['name' => 'User @ Localhost', 'label' => 'User @ Localhost (username@localhost)', 'uuid' => 'uid', 'type' => '', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'username@localhost', 'server' => 'localhost']]], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
                                false,
                                true,
                        ],
@@ -264,7 +264,7 @@ class RemotePluginTest extends TestCase {
                                        ],
                                ],
                                false,
-                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote']]]]],
+                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'test (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'test@remote', 'server' => 'remote'], 'uuid' => 'test', 'name' => 'test']]]],
                                false,
                                true,
                        ],
@@ -370,7 +370,7 @@ class RemotePluginTest extends TestCase {
                                        ],
                                ],
                                false,
-                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space@remote', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote']]]]],
+                               ['remotes' => [], 'exact' => ['remotes' => [['label' => 'user space (remote)', 'value' => ['shareType' => Share::SHARE_TYPE_REMOTE, 'shareWith' => 'user space@remote', 'server' => 'remote'], 'uuid' => 'user space', 'name' => 'user space']]]],
                                false,
                                true,
                        ],