From 4c527a8b8884bf32e1a5c293c1a803de8547c1d8 Mon Sep 17 00:00:00 2001 From: Reza Soltani Date: Mon, 27 Feb 2023 08:47:04 +0000 Subject: [PATCH] pass shareType to federatedShareProvider dynamicly --- .../lib/FederatedShareProvider.php | 5 +++-- apps/federatedfilesharing/lib/Notifications.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/apps/federatedfilesharing/lib/FederatedShareProvider.php b/apps/federatedfilesharing/lib/FederatedShareProvider.php index 5989f3af249e..fabffc21efb7 100644 --- a/apps/federatedfilesharing/lib/FederatedShareProvider.php +++ b/apps/federatedfilesharing/lib/FederatedShareProvider.php @@ -229,7 +229,7 @@ protected function createFederatedShare(IShare $share) { $share->getExpirationDate(), $token ); - + try { $sharedBy = $share->getSharedBy(); if ($this->userManager->userExists($sharedBy)) { @@ -248,7 +248,8 @@ protected function createFederatedShare(IShare $share) { $sharedByAddress, $token, $share->getNode()->getName(), - $shareId + $shareId, + $share->getShareType() ); /* Check for failure or null return from sending and pick up an error message diff --git a/apps/federatedfilesharing/lib/Notifications.php b/apps/federatedfilesharing/lib/Notifications.php index 1f6ad259370c..e28f24d6fb90 100644 --- a/apps/federatedfilesharing/lib/Notifications.php +++ b/apps/federatedfilesharing/lib/Notifications.php @@ -98,7 +98,8 @@ public function sendRemoteShare( Address $sharedByAddress, $token, $name, - $remote_id + $remote_id, + $shareType ) { error_log("sendRemoteShare"); $remoteShareSuccess = false; @@ -109,7 +110,8 @@ public function sendRemoteShare( $sharedByAddress, $token, $name, - $remote_id + $remote_id, + $shareType ); if (!$remoteShareSuccess) { $remoteShareSuccess = $this->sendPreOcmRemoteShare( @@ -402,8 +404,12 @@ protected function tryHttpPostToShareEndpoint($remoteDomain, $urlSuffix, array $ * @return bool * @throws \Exception */ - protected function sendOcmRemoteShare(Address $shareWithAddress, Address $ownerAddress, Address $sharedByAddress, $token, $name, $remote_id) { + protected function sendOcmRemoteShare(Address $shareWithAddress, Address $ownerAddress, Address $sharedByAddress, $token, $name, $remote_id, $shareType) { error_log("sendOcmRemoteShare"); + $_shareType = 'user'; + if($shareType){ + $_shareType = 'group'; + } $fields = [ 'shareWith' => $shareWithAddress->getCloudId(), @@ -413,7 +419,7 @@ protected function sendOcmRemoteShare(Address $shareWithAddress, Address $ownerA 'ownerDisplayName' => $ownerAddress->getDisplayName(), 'sender' => $sharedByAddress->getCloudId(), 'senderDisplayName' => $sharedByAddress->getDisplayName(), - 'shareType' => 'user', + 'shareType' => $_shareType, 'resourceType' => 'file', 'protocol' => [ 'name' => 'webdav',