Browse Source

Extend data returned when searching remote shares

Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
tags/v18.0.0beta1
John Molakvoæ (skjnldsv) 5 years ago
parent
commit
ea6f423e2c

+ 1
- 1
build/integration/sharees_features/sharees.feature View 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

+ 1
- 1
build/integration/sharees_features/sharees_provisioningapiv2.feature View 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

+ 21
- 1
lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php View 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);
}
}

}

+ 4
- 1
lib/private/Collaboration/Collaborators/RemotePlugin.php View 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,
],
];
}

+ 5
- 5
tests/lib/Collaboration/Collaborators/RemotePluginTest.php View 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,
],

Loading…
Cancel
Save