Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup federation phase 1 #32086

Merged
merged 5 commits into from
Jul 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/dav/appinfo/v1/publicwebdav.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@

$server = $serverFactory->createServer($baseuri, $requestUri, $authBackend, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin) {
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
// this is what is thrown when trying to access a non-existing share
Expand Down
2 changes: 1 addition & 1 deletion apps/federatedfilesharing/appinfo/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*
*/

$app = new \OCA\FederatedFileSharing\AppInfo\Application('federatedfilesharing');
$app = new \OCA\FederatedFileSharing\AppInfo\Application();

use OCA\FederatedFileSharing\Notifier;
use OCP\Share\Events\AcceptShare;
Expand Down
14 changes: 14 additions & 0 deletions apps/federatedfilesharing/appinfo/routes.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

return [
'ocs' => [
['root' => '/cloud', 'name' => 'RequestHandler#createShare', 'url' => '/shares', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#reShare', 'url' => '/shares/{id}/reshare', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#updatePermissions', 'url' => '/shares/{id}/permissions', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#acceptShare', 'url' => '/shares/{id}/accept', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#declineShare', 'url' => '/shares/{id}/decline', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#unshare', 'url' => '/shares/{id}/unshare', 'verb' => 'POST'],
['root' => '/cloud', 'name' => 'RequestHandler#revoke', 'url' => '/shares/{id}/revoke', 'verb' => 'POST'],
]
];
86 changes: 81 additions & 5 deletions apps/federatedfilesharing/lib/AppInfo/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,90 @@

namespace OCA\FederatedFileSharing\AppInfo;

use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\DiscoveryManager;
use OCA\FederatedFileSharing\FederatedShareProvider;
use OCA\FederatedFileSharing\FedShareManager;
use OCA\FederatedFileSharing\Notifications;
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
use OCA\FederatedFileSharing\TokenHandler;
use OCP\AppFramework\App;

class Application extends App {

/** @var FederatedShareProvider */
protected $federatedShareProvider;

/**
* Application constructor.
*/
public function __construct() {
parent::__construct('federatedfilesharing');
$container = $this->getContainer();
$server = $container->getServer();

$container->registerService(
'AddressHandler',
function ($c) use ($server) {
return new AddressHandler(
$server->getURLGenerator(),
$server->getL10N('federatedfilesharing')
);
}
);

$container->registerService(
'DiscoveryManager',
function ($c) use ($server) {
return new DiscoveryManager(
$server->getMemCacheFactory(),
$server->getHTTPClientService()
);
}
);

$container->registerService(
'Notifications',
function ($c) use ($server) {
return new Notifications(
$c->query('AddressHandler'),
$server->getHTTPClientService(),
$c->query('DiscoveryManager'),
$server->getJobList(),
$server->getConfig()
);
}
);

$container->registerService(
'FederatedShareManager',
function ($c) use ($server) {
return new FedShareManager(
$this->getFederatedShareProvider(),
$server->getUserManager(),
$server->getActivityManager(),
$server->getLogger()
);
}
);

$container->registerService(
'RequestHandlerController',
function ($c) use ($server) {
return new RequestHandlerController(
$c->query('AppName'),
$c->query('Request'),
$this->getFederatedShareProvider(),
$server->getDatabaseConnection(),
$c->query('Notifications'),
$c->query('AddressHandler'),
$c->query('FederatedShareManager'),
$server->getEventDispatcher()
);
}
);
}

/**
* get instance of federated share provider
*
Expand All @@ -45,26 +121,26 @@ public function getFederatedShareProvider() {
* initialize federated share provider
*/
protected function initFederatedShareProvider() {
$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
$addressHandler = new AddressHandler(
\OC::$server->getURLGenerator(),
\OC::$server->getL10N('federatedfilesharing')
);
$discoveryManager = new \OCA\FederatedFileSharing\DiscoveryManager(
$discoveryManager = new DiscoveryManager(
\OC::$server->getMemCacheFactory(),
\OC::$server->getHTTPClientService()
);
$notifications = new \OCA\FederatedFileSharing\Notifications(
$notifications = new Notifications(
$addressHandler,
\OC::$server->getHTTPClientService(),
$discoveryManager,
\OC::$server->getJobList(),
\OC::$server->getConfig()
);
$tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
$tokenHandler = new TokenHandler(
\OC::$server->getSecureRandom()
);

$this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
$this->federatedShareProvider = new FederatedShareProvider(
\OC::$server->getDatabaseConnection(),
$addressHandler,
$notifications,
Expand Down
Loading