summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorBjoern Schiessle <bjoern@schiessle.org>2018-05-09 17:06:35 +0200
committerBjoern Schiessle <bjoern@schiessle.org>2018-07-02 11:29:27 +0200
commitdb428ea5471a5be5517911b3bf2f3a6d3f86e297 (patch)
tree3921525a302150e75d968a47dff14be79f9ffa3b /apps/files_sharing/lib
parenta3948e8a126d6f84629841c8886fe0819ab04ad5 (diff)
downloadnextcloud-server-db428ea5471a5be5517911b3bf2f3a6d3f86e297.tar.gz
nextcloud-server-db428ea5471a5be5517911b3bf2f3a6d3f86e297.zip
send accept share notification (WIP)
Signed-off-by: Bjoern Schiessle <bjoern@schiessle.org>
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/AppInfo/Application.php2
-rw-r--r--apps/files_sharing/lib/External/Manager.php45
-rw-r--r--apps/files_sharing/lib/Hooks.php2
3 files changed, 49 insertions, 0 deletions
diff --git a/apps/files_sharing/lib/AppInfo/Application.php b/apps/files_sharing/lib/AppInfo/Application.php
index e0c40730b31..e6ab4eb2cf1 100644
--- a/apps/files_sharing/lib/AppInfo/Application.php
+++ b/apps/files_sharing/lib/AppInfo/Application.php
@@ -103,6 +103,8 @@ class Application extends App {
$server->getHTTPClientService(),
$server->getNotificationManager(),
$server->query(\OCP\OCS\IDiscoveryService::class),
+ $server->getCloudFederationProviderManager(),
+ $server->getCloudFederationFactory(),
$uid
);
});
diff --git a/apps/files_sharing/lib/External/Manager.php b/apps/files_sharing/lib/External/Manager.php
index c9303ac224c..cb1e947f603 100644
--- a/apps/files_sharing/lib/External/Manager.php
+++ b/apps/files_sharing/lib/External/Manager.php
@@ -33,6 +33,8 @@ namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
use OCA\Files_Sharing\Helper;
+use OCP\Federation\ICloudFederationFactory;
+use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files;
use OCP\Files\Storage\IStorageFactory;
use OCP\Http\Client\IClientService;
@@ -79,6 +81,12 @@ class Manager {
*/
private $discoveryService;
+ /** @var ICloudFederationProviderManager */
+ private $cloudFederationProviderManager;
+
+ /** @var ICloudFederationFactory */
+ private $cloudFederationFactory;
+
/**
* @param IDBConnection $connection
* @param \OC\Files\Mount\Manager $mountManager
@@ -86,6 +94,8 @@ class Manager {
* @param IClientService $clientService
* @param IManager $notificationManager
* @param IDiscoveryService $discoveryService
+ * @param ICloudFederationProviderManager $cloudFederationProviderManager
+ * @param ICloudFederationFactory $cloudFederationFactory
* @param string $uid
*/
public function __construct(IDBConnection $connection,
@@ -94,6 +104,8 @@ class Manager {
IClientService $clientService,
IManager $notificationManager,
IDiscoveryService $discoveryService,
+ ICloudFederationProviderManager $cloudFederationProviderManager,
+ ICloudFederationFactory $cloudFederationFactory,
$uid) {
$this->connection = $connection;
$this->mountManager = $mountManager;
@@ -102,6 +114,8 @@ class Manager {
$this->uid = $uid;
$this->notificationManager = $notificationManager;
$this->discoveryService = $discoveryService;
+ $this->cloudFederationProviderManager = $cloudFederationProviderManager;
+ $this->cloudFederationFactory = $cloudFederationFactory;
}
/**
@@ -274,6 +288,12 @@ class Manager {
*/
private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
+ $result = $this->tryOCMEndPoint($remote, $token, $remoteId, $feedback);
+
+ if($result === true) {
+ return true;
+ }
+
$federationEndpoints = $this->discoveryService->discover($remote, 'FEDERATED_SHARING');
$endpoint = isset($federationEndpoints['share']) ? $federationEndpoints['share'] : '/ocs/v2.php/cloud/shares';
@@ -300,6 +320,31 @@ class Manager {
}
/**
+ * try send accept message to ocm end-point
+ *
+ * @param string $remoteDomain
+ * @param string $token
+ * @param $remoteId
+ * @param string $feedback
+ * @return mixed
+ */
+ protected function tryOCMEndPoint($remoteDomain, $token, $remoteId, $feedback) {
+ switch ($feedback) {
+ case 'accept':
+ $notification = $this->cloudFederationFactory->getCloudFederationNotification();
+ $notification->setMessage('SHARE_ACCEPTED', 'file',
+ [
+ 'id' => $remoteId,
+ 'access_token' => $token
+ ]
+ );
+ return $this->cloudFederationProviderManager->sendNotification($remoteDomain, $notification);
+ }
+
+ }
+
+
+ /**
* remove '/user/files' from the path and trailing slashes
*
* @param string $path
diff --git a/apps/files_sharing/lib/Hooks.php b/apps/files_sharing/lib/Hooks.php
index 51511ca6b64..cd66fd7702e 100644
--- a/apps/files_sharing/lib/Hooks.php
+++ b/apps/files_sharing/lib/Hooks.php
@@ -40,6 +40,8 @@ class Hooks {
\OC::$server->getHTTPClientService(),
\OC::$server->getNotificationManager(),
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
+ \OC::$server->getCloudFederationProviderManager(),
+ \OC::$server->getCloudFederationFactory(),
$params['uid']);
$manager->removeUserShares($params['uid']);