Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-05-30 18:44:08 +0300
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-02 12:29:28 +0300
commit41a1528888062610af58e319ce7bfa3ef8784da3 (patch)
tree4e650690a6569ea1f0633a1b46974014a75dd12b /apps/federatedfilesharing/lib/Controller
parentb7b84305a3388af3b678c95d105f6553952b0959 (diff)
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.php50
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
*