summaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib
diff options
context:
space:
mode:
authorThomas Müller <thomas.mueller@tmit.eu>2016-03-01 11:27:28 +0100
committerThomas Müller <thomas.mueller@tmit.eu>2016-03-01 11:27:28 +0100
commit5fe5233f419624dc3eac8ee4bf95a38b001ea6fd (patch)
tree4c0b5ea576ec67cc2d5f57ccb186e65276d1cc3c /apps/files_sharing/lib
parent73e145cf63e94f68dc1f129da14e470695d46abd (diff)
parent88fc5149eddcbeaf41358c0eb56be45ad2c94a59 (diff)
downloadnextcloud-server-5fe5233f419624dc3eac8ee4bf95a38b001ea6fd.tar.gz
nextcloud-server-5fe5233f419624dc3eac8ee4bf95a38b001ea6fd.zip
Merge pull request #22681 from owncloud/add-autodiscovery-for-ocs
Add autodiscovery support to server-to-server sharing implementation
Diffstat (limited to 'apps/files_sharing/lib')
-rw-r--r--apps/files_sharing/lib/external/manager.php18
-rw-r--r--apps/files_sharing/lib/external/storage.php7
-rw-r--r--apps/files_sharing/lib/hooks.php6
3 files changed, 26 insertions, 5 deletions
diff --git a/apps/files_sharing/lib/external/manager.php b/apps/files_sharing/lib/external/manager.php
index 84de1da69f6..ec487449625 100644
--- a/apps/files_sharing/lib/external/manager.php
+++ b/apps/files_sharing/lib/external/manager.php
@@ -27,6 +27,7 @@
namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
+use OCA\FederatedFileSharing\DiscoveryManager;
use OCP\Files;
use OCP\Notification\IManager;
@@ -62,6 +63,8 @@ class Manager {
* @var IManager
*/
private $notificationManager;
+ /** @var DiscoveryManager */
+ private $discoveryManager;
/**
* @param \OCP\IDBConnection $connection
@@ -69,16 +72,23 @@ class Manager {
* @param \OCP\Files\Storage\IStorageFactory $storageLoader
* @param \OC\HTTPHelper $httpHelper
* @param IManager $notificationManager
+ * @param DiscoveryManager $discoveryManager
* @param string $uid
*/
- public function __construct(\OCP\IDBConnection $connection, \OC\Files\Mount\Manager $mountManager,
- \OCP\Files\Storage\IStorageFactory $storageLoader, \OC\HTTPHelper $httpHelper, IManager $notificationManager, $uid) {
+ public function __construct(\OCP\IDBConnection $connection,
+ \OC\Files\Mount\Manager $mountManager,
+ \OCP\Files\Storage\IStorageFactory $storageLoader,
+ \OC\HTTPHelper $httpHelper,
+ IManager $notificationManager,
+ DiscoveryManager $discoveryManager,
+ $uid) {
$this->connection = $connection;
$this->mountManager = $mountManager;
$this->storageLoader = $storageLoader;
$this->httpHelper = $httpHelper;
$this->uid = $uid;
$this->notificationManager = $notificationManager;
+ $this->discoveryManager = $discoveryManager;
}
/**
@@ -246,13 +256,13 @@ class Manager {
*/
private function sendFeedbackToRemote($remote, $token, $remoteId, $feedback) {
- $url = rtrim($remote, '/') . \OCP\Share::BASE_PATH_TO_SHARE_API . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT;
+ $url = rtrim($remote, '/') . $this->discoveryManager->getShareEndpoint($remote) . '/' . $remoteId . '/' . $feedback . '?format=' . \OCP\Share::RESPONSE_FORMAT;
$fields = array('token' => $token);
$result = $this->httpHelper->post($url, $fields);
$status = json_decode($result['result'], true);
- return ($result['success'] && $status['ocs']['meta']['statuscode'] === 100);
+ return ($result['success'] && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200));
}
/**
diff --git a/apps/files_sharing/lib/external/storage.php b/apps/files_sharing/lib/external/storage.php
index ed391f331ad..41f7bef589b 100644
--- a/apps/files_sharing/lib/external/storage.php
+++ b/apps/files_sharing/lib/external/storage.php
@@ -67,6 +67,11 @@ class Storage extends DAV implements ISharedStorage {
private $manager;
public function __construct($options) {
+ $discoveryManager = new DiscoveryManager(
+ \OC::$server->getMemCacheFactory(),
+ \OC::$server->getHTTPClientService()
+ );
+
$this->manager = $options['manager'];
$this->certificateManager = $options['certificateManager'];
$this->remote = $options['remote'];
@@ -79,7 +84,7 @@ class Storage extends DAV implements ISharedStorage {
$root = '';
}
$secure = $protocol === 'https';
- $root = rtrim($root, '/') . '/public.php/webdav';
+ $root = rtrim($root, '/') . $discoveryManager->getWebDavEndpoint($this->remote);
$this->mountPoint = $options['mountpoint'];
$this->token = $options['token'];
parent::__construct(array(
diff --git a/apps/files_sharing/lib/hooks.php b/apps/files_sharing/lib/hooks.php
index 166905b9aa4..e3f24d02268 100644
--- a/apps/files_sharing/lib/hooks.php
+++ b/apps/files_sharing/lib/hooks.php
@@ -25,16 +25,22 @@
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
+use OCA\FederatedFileSharing\DiscoveryManager;
class Hooks {
public static function deleteUser($params) {
+ $discoveryManager = new DiscoveryManager(
+ \OC::$server->getMemCacheFactory(),
+ \OC::$server->getHTTPClientService()
+ );
$manager = new External\Manager(
\OC::$server->getDatabaseConnection(),
\OC\Files\Filesystem::getMountManager(),
\OC\Files\Filesystem::getLoader(),
\OC::$server->getHTTPHelper(),
\OC::$server->getNotificationManager(),
+ $discoveryManager,
$params['uid']);
$manager->removeUserShares($params['uid']);