From 0a33cdee0cbd7b76180e18e50db8ce8938086789 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Thu, 11 Feb 2016 21:17:22 +0100 Subject: [PATCH 1/2] If the initiator no longer exists return UID It can happen that the share initiator is deleted. Because of the new resharing behaviour this share then still exists. We just can fetch the displayname properly. --- apps/files_sharing/api/share20ocs.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 67a94aaf8a..993a069fe6 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -91,7 +91,7 @@ class Share20OCS { 'id' => $share->getId(), 'share_type' => $share->getShareType(), 'uid_owner' => $share->getSharedBy(), - 'displayname_owner' => $sharedBy->getDisplayName(), + 'displayname_owner' => $sharedBy !== null ? $sharedBy->getDisplayName() : $share->getSharedBy(), 'permissions' => $share->getPermissions(), 'stime' => $share->getShareTime()->getTimestamp(), 'parent' => null, From 479c458428ef56792f76ab0ab17a4933c6824cc2 Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Fri, 12 Feb 2016 10:44:34 +0100 Subject: [PATCH 2/2] The owner and recipient can also be null If we have backend hickups it can be that we are unable to retrive the owner and recipient user as well. In such cases just return the UID. --- apps/files_sharing/api/share20ocs.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/files_sharing/api/share20ocs.php b/apps/files_sharing/api/share20ocs.php index 993a069fe6..688ed5b3ee 100644 --- a/apps/files_sharing/api/share20ocs.php +++ b/apps/files_sharing/api/share20ocs.php @@ -98,7 +98,7 @@ class Share20OCS { 'expiration' => null, 'token' => null, 'uid_file_owner' => $share->getShareOwner(), - 'displayname_file_owner' => $shareOwner->getDisplayName(), + 'displayname_file_owner' => $shareOwner !== null ? $shareOwner->getDisplayName() : $share->getShareOwner(), ]; $node = $share->getNode(); @@ -117,8 +117,8 @@ class Share20OCS { if ($share->getShareType() === \OCP\Share::SHARE_TYPE_USER) { $sharedWith = $this->userManager->get($share->getSharedWith()); - $result['share_with'] = $sharedWith->getUID(); - $result['share_with_displayname'] = $sharedWith->getDisplayName(); + $result['share_with'] = $share->getSharedWith(); + $result['share_with_displayname'] = $sharedWith !== null ? $sharedWith->getDisplayName() : $share->getSharedWith(); } else if ($share->getShareType() === \OCP\Share::SHARE_TYPE_GROUP) { $result['share_with'] = $share->getSharedWith(); $result['share_with_displayname'] = $share->getSharedWith();