summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMaxence Lange <maxence@nextcloud.com>2017-06-06 10:21:42 -0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-05-21 01:24:45 +0200
commit0009adae80cf9b3f8bcc40bd3f75d2a3f2cee6ad (patch)
tree22a62264854300ff73a62bcf94262d5fcad86adf /apps/files_sharing
parentca089b9412af79cc696342968a657991755a2e2e (diff)
downloadnextcloud-server-0009adae80cf9b3f8bcc40bd3f75d2a3f2cee6ad.tar.gz
nextcloud-server-0009adae80cf9b3f8bcc40bd3f75d2a3f2cee6ad.zip
SharedWithDisplayName + SharedWithAvatar
Signed-off-by: Maxence Lange <maxence@nextcloud.com> Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'apps/files_sharing')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php9
-rw-r--r--apps/files_sharing/tests/Controller/ShareAPIControllerTest.php125
2 files changed, 132 insertions, 2 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 30a8ded2a4a..73c3e5951b0 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -212,8 +212,13 @@ class ShareAPIController extends OCSController {
// "name (type, owner) [id]", depending on the Circles app version.
$hasCircleId = (substr($share->getSharedWith(), -1) === ']');
- $displayNameLength = ($hasCircleId? strrpos($share->getSharedWith(), ' '): strlen($share->getSharedWith()));
- $result['share_with_displayname'] = substr($share->getSharedWith(), 0, $displayNameLength);
+ $result['share_with_displayname'] = $share->getSharedWithDisplayName();
+ if (empty($result['share_with_displayname'])) {
+ $displayNameLength = ($hasCircleId? strrpos($share->getSharedWith(), ' '): strlen($share->getSharedWith()));
+ $result['share_with_displayname'] = substr($share->getSharedWith(), 0, $displayNameLength);
+ }
+
+ $result['share_with_avatar'] = $share->getSharedWithAvatar();
$shareWithStart = ($hasCircleId? strrpos($share->getSharedWith(), '[') + 1: 0);
$shareWithLength = ($hasCircleId? -1: strpos($share->getSharedWith(), ' '));
diff --git a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
index 89a21d7d1e4..c27680ba670 100644
--- a/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
+++ b/apps/files_sharing/tests/Controller/ShareAPIControllerTest.php
@@ -2074,6 +2074,131 @@ class ShareAPIControllerTest extends TestCase {
], $share, [], false
];
+ // Circle with id, display name and avatar set by the Circles app
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ ->setSharedBy('initiator')
+ ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
+ ->setSharedWithDisplayName('The display name')
+ ->setSharedWithAvatar('path/to/the/avatar')
+ ->setShareOwner('owner')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($folder)
+ ->setShareTime(new \DateTime('2000-01-01T00:01:02'))
+ ->setTarget('myTarget')
+ ->setId(42);
+
+ $result[] = [
+ [
+ 'id' => 42,
+ 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ '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' => '4815162342',
+ 'share_with_displayname' => 'The display name',
+ 'share_with_avatar' => 'path/to/the/avatar',
+ 'mail_send' => 0,
+ 'mimetype' => 'myFolderMimeType',
+ ], $share, [], false
+ ];
+
+ // Circle with id set by the Circles app
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ ->setSharedBy('initiator')
+ ->setSharedWith('Circle (Public circle, circleOwner) [4815162342]')
+ ->setShareOwner('owner')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($folder)
+ ->setShareTime(new \DateTime('2000-01-01T00:01:02'))
+ ->setTarget('myTarget')
+ ->setId(42);
+
+ $result[] = [
+ [
+ 'id' => 42,
+ 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ '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' => '4815162342',
+ 'share_with_displayname' => 'Circle (Public circle, circleOwner)',
+ 'share_with_avatar' => '',
+ 'mail_send' => 0,
+ 'mimetype' => 'myFolderMimeType',
+ ], $share, [], false
+ ];
+
+ // Circle with id not set by the Circles app
+ $share = \OC::$server->getShareManager()->newShare();
+ $share->setShareType(\OCP\Share::SHARE_TYPE_CIRCLE)
+ ->setSharedBy('initiator')
+ ->setSharedWith('Circle (Public circle, circleOwner)')
+ ->setShareOwner('owner')
+ ->setPermissions(\OCP\Constants::PERMISSION_READ)
+ ->setNode($folder)
+ ->setShareTime(new \DateTime('2000-01-01T00:01:02'))
+ ->setTarget('myTarget')
+ ->setId(42);
+
+ $result[] = [
+ [
+ 'id' => 42,
+ 'share_type' => \OCP\Share::SHARE_TYPE_CIRCLE,
+ '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' => 'Circle',
+ 'share_with_displayname' => 'Circle (Public circle, circleOwner)',
+ 'share_with_avatar' => '',
+ 'mail_send' => 0,
+ 'mimetype' => 'myFolderMimeType',
+ ], $share, [], false
+ ];
+
$share = \OC::$server->getShareManager()->newShare();
$share->setShareType(\OCP\Share::SHARE_TYPE_USER)
->setSharedBy('initiator')