From df5cd18394dea317b51432f7a214d4f88f5ba2e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Mar 2018 04:23:46 +0100 Subject: [PATCH 1/2] Set "share_with" field to the ID of the circle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a share is shared with a circle the "share_with" field returned by the API endpoint was always set to the name of the circle. However, the name is not enough to identify a circle. The Circles app now provides the ID of the circle in the "shared with" field of a Share, so this commit modifies the API endpoint to set the "share_with" field to the ID of the circle when provided by the Circles app. Signed-off-by: Daniel Calviño Sánchez --- .../lib/Controller/ShareAPIController.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php index 10876e1656821..82a93c446e2e0 100644 --- a/apps/files_sharing/lib/Controller/ShareAPIController.php +++ b/apps/files_sharing/lib/Controller/ShareAPIController.php @@ -200,8 +200,16 @@ protected function formatShare(\OCP\Share\IShare $share, Node $recipientNode = n $result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL'); $result['token'] = $share->getToken(); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_CIRCLE) { - $result['share_with_displayname'] = $share->getSharedWith(); - $result['share_with'] = explode(' ', $share->getSharedWith(), 2)[0]; + // getSharedWith() returns either "name (type, owner)" or + // "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); + + $shareWithStart = ($hasCircleId? strrpos($share->getSharedWith(), '[') + 1: 0); + $shareWithLength = ($hasCircleId? -1: strpos($share->getSharedWith(), ' ')); + $result['share_with'] = substr($share->getSharedWith(), $shareWithStart, $shareWithLength); } From 3bd92edd9cff16f4304e526d57fa71f6ecfb3ca0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 16 Mar 2018 04:28:54 +0100 Subject: [PATCH 2/2] Use the display name in the avatar for a circle share MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before, the avatar for a circle share was generated using the "share_with" field as the seed for "imageplaceholder". Due to this, when the "share_with" field is set to the circle ID the character shown in the avatar was just a random character instead of the first character of the display name. Now the "share_with" is still used as the seed for the colour, but the display name is used as the text of the avatar. This adds support for "share_with" fields set to the circle ID while being backwards compatible with "share_with" fields set to the circle name. Note that when "share_with" fields is set to the circle name the colour of the avatar is different in the list of suggested sharees and in the list of current sharees, but that also happened before these changes (due to a different seed being used in each place). Signed-off-by: Daniel Calviño Sánchez --- core/js/sharedialogshareelistview.js | 2 +- core/js/sharedialogview.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/core/js/sharedialogshareelistview.js b/core/js/sharedialogshareelistview.js index 6c256d3de379b..8ec53810b5129 100644 --- a/core/js/sharedialogshareelistview.js +++ b/core/js/sharedialogshareelistview.js @@ -241,7 +241,7 @@ shareWithTitle: shareWithTitle, shareType: shareType, shareId: this.model.get('shares')[shareIndex].id, - modSeed: shareType !== OC.Share.SHARE_TYPE_USER, + modSeed: shareType !== OC.Share.SHARE_TYPE_USER && shareType !== OC.Share.SHARE_TYPE_CIRCLE, isRemoteShare: shareType === OC.Share.SHARE_TYPE_REMOTE, isMailShare: shareType === OC.Share.SHARE_TYPE_EMAIL, isCircleShare: shareType === OC.Share.SHARE_TYPE_CIRCLE, diff --git a/core/js/sharedialogview.js b/core/js/sharedialogview.js index 6b65e46b2547e..d2c6349014158 100644 --- a/core/js/sharedialogview.js +++ b/core/js/sharedialogview.js @@ -338,7 +338,7 @@ } var insert = $("