Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Extend data returned when searching remote shares
Signed-off-by: John Molakvoæ (skjnldsv) <[email protected]>
  • Loading branch information
skjnldsv authored and danxuliu committed Oct 29, 2019
commit ea6f423e2c8e50cf1357a0e2182dc4c9a9bf981e
2 changes: 1 addition & 1 deletion build/integration/sharees_features/sharees.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 21 additions & 1 deletion lib/private/Collaboration/Collaborators/RemoteGroupPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$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,
],
];
}
Expand All @@ -71,4 +75,20 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
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);
}
}

}
5 changes: 4 additions & 1 deletion lib/private/Collaboration/Collaborators/RemotePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,13 @@ public function search($search, $limit, $offset, ISearchResult $searchResult) {
$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,
],
];
}
Expand Down
10 changes: 5 additions & 5 deletions tests/lib/Collaboration/Collaborators/RemotePluginTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,15 +152,15 @@ public function dataGetRemote() {
'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,
],
[
'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,
],
Expand Down Expand Up @@ -238,7 +238,7 @@ public function dataGetRemote() {
],
],
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,
],
Expand All @@ -264,7 +264,7 @@ public function dataGetRemote() {
],
],
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,
],
Expand Down Expand Up @@ -370,7 +370,7 @@ public function dataGetRemote() {
],
],
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,
],
Expand Down