summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-07-12 20:51:41 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-07-12 21:24:55 +0200
commit243df99fcfcd384a8ad4b54e89c6d621bb81685b (patch)
treebe15c10c8bde8d2647f1d4bf5a5a5a856b8e1a69
parent09d5b61c9e468cdc0b92db27946140e68192e2e5 (diff)
downloadnextcloud-server-243df99fcfcd384a8ad4b54e89c6d621bb81685b.tar.gz
nextcloud-server-243df99fcfcd384a8ad4b54e89c6d621bb81685b.zip
Fix formatting of email and circle shares
Due to a misplaced "||" instead of "===" the condition was always met, so every share type in the conditional chain after the remote and remote group shares was formatted as a remote/remote group share. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php2
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php68
2 files changed, 62 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 59b763ecf81..9ad0e080f46 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -198,7 +198,7 @@ class ShareAPIController extends OCSController {
$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();
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 2c638fe4ed6..4a2c486765f 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -2088,6 +2088,47 @@ class ShareAPIControllerTest extends TestCase {
[], $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;
}
@@ -2131,15 +2172,28 @@ class ShareAPIControllerTest extends TestCase {
$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]);