From 70917902ec43e7a7cd87f0dc2b149f0ab83a73c3 Mon Sep 17 00:00:00 2001 From: Navid Shokri Date: Fri, 3 Feb 2023 12:52:34 +0330 Subject: [PATCH] Update ExternalSharesController.php decline share finished --- .../Controllers/ExternalSharesController.php | 33 +++++++++++++------ 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/apps/files_sharing/lib/Controllers/ExternalSharesController.php b/apps/files_sharing/lib/Controllers/ExternalSharesController.php index 8b34268c2033..d66cffa608be 100644 --- a/apps/files_sharing/lib/Controllers/ExternalSharesController.php +++ b/apps/files_sharing/lib/Controllers/ExternalSharesController.php @@ -91,11 +91,13 @@ public function index() { * @param int $id * @return JSONResponse */ - public function create($id) { - $shareInfo = $this->externalManager->getShare($id); + public function create($id, $share_type) { + $manager = $this->getRelatedManager($share_type); + $shareInfo = $manager->getShare($id); + if ($shareInfo !== false) { - $mountPoint = $this->externalManager->getShareRecipientMountPoint($shareInfo); - $fileId = $this->externalManager->getShareFileId($shareInfo, $mountPoint); + $mountPoint = $manager->getShareRecipientMountPoint($shareInfo); + $fileId = $manager->getShareFileId($shareInfo, $mountPoint); $event = new GenericEvent( null, @@ -109,8 +111,8 @@ public function create($id) { 'shareRecipient' => $shareInfo['user'], ] ); - $this->dispatcher->dispatch('remoteshare.accepted', $event); - $this->externalManager->acceptShare($id); + $this->dispatcher->dispatch($event, 'remoteshare.accepted', $event); + $manager->acceptShare($id); } return new JSONResponse(); } @@ -122,8 +124,9 @@ public function create($id) { * @param integer $id * @return JSONResponse */ - public function destroy($id) { - $shareInfo = $this->externalManager->getShare($id); + public function destroy($id, $share_type) { + $manager = $this->getRelatedManager($share_type); + $shareInfo = $manager->getShare($id); if ($shareInfo !== false) { $event = new GenericEvent( null, @@ -134,11 +137,21 @@ public function destroy($id) { 'remoteUrl' => $shareInfo['remote'] ] ); - $this->dispatcher->dispatch('remoteshare.declined', $event); - $this->externalManager->declineShare($id); + $this->dispatcher->dispatch($event, 'remoteshare.declined'); + $manager->declineShare($id); } return new JSONResponse(); } + + private function getRelatedManager($share_type){ + if($share_type === "group" && $this->groupExternalManager !== null) { + $manager = $this->groupExternalManager; + } else { + $manager = $this->externalManager; + } + return $manager; + + } /** * Test whether the specified remote is accessible