Skip to content

Commit

Permalink
Merge pull request #10224 from nextcloud/fix-formatting-of-email-and-…
Browse files Browse the repository at this point in the history
…circle-shares

Fix formatting of email and circle shares
  • Loading branch information
MorrisJobke authored Jul 13, 2018
2 parents 9f186e1 + 243df99 commit f2b92c4
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 8 deletions.
2 changes: 1 addition & 1 deletion apps/files_sharing/lib/Controller/ShareAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n
$result['token'] = $share->getToken();
$result['url'] = $this->urlGenerator->linkToRouteAbsolute('files_sharing.sharecontroller.showShare', ['token' => $share->getToken()]);

} else if ($share->getShareType() === Share::SHARE_TYPE_REMOTE || $share->getShareType() || Share::SHARE_TYPE_REMOTE_GROUP) {
} else if ($share->getShareType() === Share::SHARE_TYPE_REMOTE || $share->getShareType() === Share::SHARE_TYPE_REMOTE_GROUP) {
$result['share_with'] = $share->getSharedWith();
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'CLOUD');
$result['token'] = $share->getToken();
Expand Down
68 changes: 61 additions & 7 deletions apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2088,6 +2088,47 @@ public function dataFormatShare() {
[], $share, [], true
];

$share = \OC::$server->getShareManager()->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_EMAIL)
->setSharedBy('initiator')
->setSharedWith('user@server.com')
->setShareOwner('owner')
->setPermissions(\OCP\Constants::PERMISSION_READ)
->setNode($folder)
->setShareTime(new \DateTime('2000-01-01T00:01:02'))
->setTarget('myTarget')
->setId(42)
->setPassword('password');

$result[] = [
[
'id' => 42,
'share_type' => \OCP\Share::SHARE_TYPE_EMAIL,
'uid_owner' => 'initiator',
'displayname_owner' => 'initiator',
'permissions' => 1,
'stime' => 946684862,
'parent' => null,
'expiration' => null,
'token' => null,
'uid_file_owner' => 'owner',
'displayname_file_owner' => 'owner',
'path' => 'folder',
'item_type' => 'folder',
'storage_id' => 'storageId',
'storage' => 100,
'item_source' => 2,
'file_source' => 2,
'file_parent' => 1,
'file_target' => 'myTarget',
'share_with' => 'user@server.com',
'share_with_displayname' => 'mail display name',
'mail_send' => 0,
'mimetype' => 'myFolderMimeType',
'password' => 'password'
], $share, [], false
];

return $result;
}

Expand Down Expand Up @@ -2131,15 +2172,28 @@ public function testFormatShare(array $expects, \OCP\Share\IShare $share, array
$this->overwriteService(\OCP\Contacts\IManager::class, $cm);

$cm->method('search')
->with('user@server.com', ['CLOUD'])
->willReturn([
[
'CLOUD' => [
'user@server.com',
->will($this->returnValueMap([
['user@server.com', ['CLOUD'], [],
[
[
'CLOUD' => [
'user@server.com',
],
'FN' => 'foobar',
],
],
'FN' => 'foobar',
],
]);
['user@server.com', ['EMAIL'], [],
[
[
'EMAIL' => [
'user@server.com',
],
'FN' => 'mail display name',
],
],
],
]));

try {
$result = $this->invokePrivate($this->ocs, 'formatShare', [$share]);
Expand Down

0 comments on commit f2b92c4

Please sign in to comment.