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-06-04 17:36:37 +0300
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-02 12:29:28 +0300
commita176a1f318501ecf344a43b66811985eee99c426 (patch)
treea00458c6ea91393ac5101bf4173d32e5e271a6dc /apps/federatedfilesharing/lib/Controller
parentfab4e561f4f3ea9a3cf90a01c39c8d1e87ee9eab (diff)
implement unshare notification
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/federatedfilesharing/lib/Controller')
-rw-r--r--apps/federatedfilesharing/lib/Controller/RequestHandlerController.php72
1 files changed, 14 insertions, 58 deletions
diff --git a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
index 041232c83e6..0b490b57575 100644
--- a/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
+++ b/apps/federatedfilesharing/lib/Controller/RequestHandlerController.php
@@ -333,60 +333,12 @@ class RequestHandlerController extends OCSController {
$token = isset($_POST['token']) ? $_POST['token'] : null;
- $qb = $this->connection->getQueryBuilder();
- $qb->select('*')
- ->from('share_external')
- ->where(
- $qb->expr()->andX(
- $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
- $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
- )
- );
-
- $result = $qb->execute();
- $share = $result->fetch();
- $result->closeCursor();
-
- if ($token && $id && !empty($share)) {
-
- $remote = $this->cleanupRemote($share['remote']);
-
- $owner = $this->cloudIdManager->getCloudId($share['owner'], $remote);
- $mountpoint = $share['mountpoint'];
- $user = $share['user'];
-
- $qb = $this->connection->getQueryBuilder();
- $qb->delete('share_external')
- ->where(
- $qb->expr()->andX(
- $qb->expr()->eq('remote_id', $qb->createNamedParameter($id)),
- $qb->expr()->eq('share_token', $qb->createNamedParameter($token))
- )
- );
-
- $result = $qb->execute();
- $result->closeCursor();
-
- if ($share['accepted']) {
- $path = trim($mountpoint, '/');
- } else {
- $path = trim($share['name'], '/');
- }
-
- $notificationManager = \OC::$server->getNotificationManager();
- $notification = $notificationManager->createNotification();
- $notification->setApp('files_sharing')
- ->setUser($share['user'])
- ->setObject('remote_share', (int)$share['id']);
- $notificationManager->markProcessed($notification);
-
- $event = \OC::$server->getActivityManager()->generateEvent();
- $event->setApp('files_sharing')
- ->setType('remote_share')
- ->setSubject(RemoteShares::SUBJECT_REMOTE_SHARE_UNSHARED, [$owner->getId(), $path])
- ->setAffectedUser($user)
- ->setObject('remote_share', (int)$share['id'], $path);
- \OC::$server->getActivityManager()->publish($event);
+ try {
+ $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
+ $notification = ['sharedSecret' => $token];
+ $provider->notificationReceived('SHARE_UNSHARED', $id, $notification);
+ } catch (\Exception $e) {
+ $this->logger->debug('processing unshare notification failed: ' . $e->getMessage());
}
return new Http\DataResponse();
@@ -410,16 +362,20 @@ class RequestHandlerController extends OCSController {
* @throws OCSBadRequestException
*/
public function revoke($id) {
+
$token = $this->request->getParam('token');
- $share = $this->federatedShareProvider->getShareById($id);
+ $notification = $this->cloudFederationFactory->getCloudFederationNotification();
+ $notification->setMessage(['sharedSecret' => $token]);
- if ($this->verifyShare($share, $token)) {
- $this->federatedShareProvider->removeShareFromTable($share);
+ try {
+ $provider = $this->cloudFederationProviderManager->getCloudFederationProvider('file');
+ $provider->notificationReceived('SHARE_UNSHARE', $id, $notification);
return new Http\DataResponse();
+ } catch (\Exception $e) {
+ throw new OCSBadRequestException();
}
- throw new OCSBadRequestException();
}
/**