summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2018-07-13 17:29:57 +0200
committerGitHub <noreply@github.com>2018-07-13 17:29:57 +0200
commit82021b2b1bd6e6ae9c85564ba614797a1110e29c (patch)
treedcae47bf607411ae0e2e4e54ed5715aa98354c35 /apps/files_sharing
parent14314584ba88ed8d8a7c8486b61c6677a14271f2 (diff)
parent4f5814c27bc43a8f10bd35f60bc3254697c50659 (diff)
downloadnextcloud-server-82021b2b1bd6e6ae9c85564ba614797a1110e29c.tar.gz
nextcloud-server-82021b2b1bd6e6ae9c85564ba614797a1110e29c.zip
Merge pull request #5280 from nextcloud/shared-with-display-name
sharedWithDisplayName & sharedWithAvatar
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 9ad0e080f46..d30d5a05a22 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 4a2c486765f..5d376f2d4f7 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')