diff options
author | Bjoern Schiessle <bjoern@schiessle.org> | 2018-05-30 17:44:08 +0200 |
---|---|---|
committer | Bjoern Schiessle <bjoern@schiessle.org> | 2018-07-02 11:29:28 +0200 |
commit | 41a1528888062610af58e319ce7bfa3ef8784da3 (patch) | |
tree | 4e650690a6569ea1f0633a1b46974014a75dd12b /apps/federatedfilesharing/lib/Controller | |
parent | b7b84305a3388af3b678c95d105f6553952b0959 (diff) | |
download | nextcloud-server-41a1528888062610af58e319ce7bfa3ef8784da3.tar.gz nextcloud-server-41a1528888062610af58e319ce7bfa3ef8784da3.zip |
implement decline share
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federatedfilesharing/lib/Controller')
-rw-r--r-- | apps/federatedfilesharing/lib/Controller/RequestHandlerController.php | 50 |
1 files changed, 13 insertions, 37 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php index 628e306e994..8514adb5e89 100644 --- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php +++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php @@ -304,52 +304,28 @@ class RequestHandlerController extends OCSController { */ public function declineShare($id) { - if (!$this->isS2SEnabled()) { - throw new OCSException('Server does not support federated cloud sharing', 503); - } - $token = isset($_POST['token']) ? $_POST['token'] : null; - try { - $share = $this->federatedShareProvider->getShareById($id); - } catch (Share\Exceptions\ShareNotFound $e) { - return new Http\DataResponse(); - } + $notification = [ + 'sharedSecret' => $token, + 'message' => 'Recipient declined the share' + ]; - if ($this->verifyShare($share, $token)) { - if ($share->getShareOwner() !== $share->getSharedBy()) { - list(, $remote) = $this->addressHandler->splitUserRemote($share->getSharedBy()); - $remoteId = $this->federatedShareProvider->getRemoteId($share); - $this->notifications->sendDeclineShare($remote, $remoteId, $share->getToken()); - } - $this->executeDeclineShare($share); + try { + $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file'); + $provider->notificationReceived('SHARE_DECLINED', $id, $notification); + } catch (ProviderDoesNotExistsException $e) { + throw new OCSException('Server does not support federated cloud sharing', 503); + } catch (ShareNotFoundException $e) { + $this->logger->debug('Share not found: ' . $e->getMessage()); + } catch (\Exception $e) { + $this->logger->debug('internal server error, can not process notification: ' . $e->getMessage()); } return new Http\DataResponse(); } /** - * delete declined share and create a activity - * - * @param Share\IShare $share - */ - protected function executeDeclineShare(Share\IShare $share) { - $this->federatedShareProvider->removeShareFromTable($share); - $fileId = (int) $share->getNode()->getId(); - list($file, $link) = $this->getFile($this->getCorrectUid($share), $fileId); - - $event = \OC::$server->getActivityManager()->generateEvent(); - $event->setApp('files_sharing') - ->setType('remote_share') - ->setAffectedUser($this->getCorrectUid($share)) - ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_DECLINED, [$share->getSharedWith(), [$fileId => $file]]) - ->setObject('files', $fileId, $file) - ->setLink($link); - \OC::$server->getActivityManager()->publish($event); - - } - - /** * @NoCSRFRequired * @PublicPage * |