Use IBootstrap for the app federatedfilesharing
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
This commit is contained in:
parent
2c87ce60a0
commit
7e281a07bb
|
@ -66,8 +66,8 @@ $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
|
||||||
|
|
||||||
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
|
$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
|
||||||
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
|
$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
|
||||||
$federatedSharingApp = \OC::$server->query(\OCA\FederatedFileSharing\AppInfo\Application::class);
|
/** @var \OCA\FederatedFileSharing\FederatedShareProvider $shareProvider */
|
||||||
$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
$federatedShareProvider = \OC::$server->query(\OCA\FederatedFileSharing\FederatedShareProvider::class);
|
||||||
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
|
if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
|
||||||
// this is what is thrown when trying to access a non-existing share
|
// this is what is thrown when trying to access a non-existing share
|
||||||
throw new \Sabre\DAV\Exception\NotAuthenticated();
|
throw new \Sabre\DAV\Exception\NotAuthenticated();
|
||||||
|
|
|
@ -1,27 +0,0 @@
|
||||||
<?php
|
|
||||||
/**
|
|
||||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
|
||||||
*
|
|
||||||
* @author Björn Schießle <bjoern@schiessle.org>
|
|
||||||
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
|
||||||
* @author Robin Appelman <robin@icewind.nl>
|
|
||||||
*
|
|
||||||
* @license AGPL-3.0
|
|
||||||
*
|
|
||||||
* This code is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License, version 3,
|
|
||||||
* as published by the Free Software Foundation.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License, version 3,
|
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
|
||||||
|
|
||||||
\OC::$server->query(Application::class);
|
|
|
@ -12,6 +12,7 @@ return array(
|
||||||
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => $baseDir . '/../lib/Controller/MountPublicLinkController.php',
|
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => $baseDir . '/../lib/Controller/MountPublicLinkController.php',
|
||||||
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php',
|
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php',
|
||||||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
|
'OCA\\FederatedFileSharing\\FederatedShareProvider' => $baseDir . '/../lib/FederatedShareProvider.php',
|
||||||
|
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => $baseDir . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
||||||
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php',
|
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => $baseDir . '/../lib/Migration/Version1010Date20200630191755.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
|
'OCA\\FederatedFileSharing\\Notifications' => $baseDir . '/../lib/Notifications.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
|
'OCA\\FederatedFileSharing\\Notifier' => $baseDir . '/../lib/Notifier.php',
|
||||||
|
|
|
@ -27,6 +27,7 @@ class ComposerStaticInitFederatedFileSharing
|
||||||
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__ . '/..' . '/../lib/Controller/MountPublicLinkController.php',
|
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__ . '/..' . '/../lib/Controller/MountPublicLinkController.php',
|
||||||
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php',
|
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php',
|
||||||
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
|
'OCA\\FederatedFileSharing\\FederatedShareProvider' => __DIR__ . '/..' . '/../lib/FederatedShareProvider.php',
|
||||||
|
'OCA\\FederatedFileSharing\\Listeners\\LoadAdditionalScriptsListener' => __DIR__ . '/..' . '/../lib/Listeners/LoadAdditionalScriptsListener.php',
|
||||||
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php',
|
'OCA\\FederatedFileSharing\\Migration\\Version1010Date20200630191755' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191755.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
|
'OCA\\FederatedFileSharing\\Notifications' => __DIR__ . '/..' . '/../lib/Notifications.php',
|
||||||
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
|
'OCA\\FederatedFileSharing\\Notifier' => __DIR__ . '/..' . '/../lib/Notifier.php',
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
/**
|
/**
|
||||||
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
* @copyright Copyright (c) 2016, ownCloud, Inc.
|
||||||
*
|
*
|
||||||
* @author Bjoern Schiessle <bjoern@schiessle.org>
|
|
||||||
* @author Björn Schießle <bjoern@schiessle.org>
|
* @author Björn Schießle <bjoern@schiessle.org>
|
||||||
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
* @author Christoph Wurst <christoph@winzerhof-wurst.at>
|
||||||
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
* @author John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
|
||||||
|
@ -29,145 +28,35 @@
|
||||||
|
|
||||||
namespace OCA\FederatedFileSharing\AppInfo;
|
namespace OCA\FederatedFileSharing\AppInfo;
|
||||||
|
|
||||||
use OC\AppFramework\Utility\SimpleContainer;
|
use OCA\FederatedFileSharing\Listeners\LoadAdditionalScriptsListener;
|
||||||
use OCA\FederatedFileSharing\AddressHandler;
|
|
||||||
use OCA\FederatedFileSharing\Controller\RequestHandlerController;
|
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
|
||||||
use OCA\FederatedFileSharing\Notifications;
|
|
||||||
use OCA\FederatedFileSharing\Notifier;
|
use OCA\FederatedFileSharing\Notifier;
|
||||||
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
|
use OCA\FederatedFileSharing\OCM\CloudFederationProviderFiles;
|
||||||
|
use OCA\Files\Event\LoadAdditionalScriptsEvent;
|
||||||
use OCP\AppFramework\App;
|
use OCP\AppFramework\App;
|
||||||
use OCP\GlobalScale\IConfig;
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
||||||
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||||
class Application extends App {
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
||||||
|
|
||||||
/** @var FederatedShareProvider */
|
|
||||||
protected $federatedShareProvider;
|
|
||||||
|
|
||||||
|
class Application extends App implements IBootstrap {
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
parent::__construct('federatedfilesharing');
|
parent::__construct('federatedfilesharing');
|
||||||
|
}
|
||||||
|
|
||||||
$container = $this->getContainer();
|
public function register(IRegistrationContext $context): void {
|
||||||
$server = $container->getServer();
|
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadAdditionalScriptsListener::class);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function boot(IBootContext $context): void {
|
||||||
|
$server = $context->getServerContainer();
|
||||||
|
|
||||||
$cloudFederationManager = $server->getCloudFederationProviderManager();
|
$cloudFederationManager = $server->getCloudFederationProviderManager();
|
||||||
$cloudFederationManager->addCloudFederationProvider('file',
|
$cloudFederationManager->addCloudFederationProvider('file',
|
||||||
'Federated Files Sharing',
|
'Federated Files Sharing',
|
||||||
function () use ($container) {
|
function () use ($server) {
|
||||||
$server = $container->getServer();
|
return $server->query(CloudFederationProviderFiles::class);
|
||||||
return new CloudFederationProviderFiles(
|
|
||||||
$server->getAppManager(),
|
|
||||||
$server->query(FederatedShareProvider::class),
|
|
||||||
$server->query(AddressHandler::class),
|
|
||||||
$server->getLogger(),
|
|
||||||
$server->getUserManager(),
|
|
||||||
$server->getShareManager(),
|
|
||||||
$server->getCloudIdManager(),
|
|
||||||
$server->getActivityManager(),
|
|
||||||
$server->getNotificationManager(),
|
|
||||||
$server->getURLGenerator(),
|
|
||||||
$server->getCloudFederationFactory(),
|
|
||||||
$server->getCloudFederationProviderManager(),
|
|
||||||
$server->getDatabaseConnection(),
|
|
||||||
$server->getGroupManager()
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
$container->registerService('RequestHandlerController', function (SimpleContainer $c) use ($server) {
|
|
||||||
$addressHandler = new AddressHandler(
|
|
||||||
$server->getURLGenerator(),
|
|
||||||
$server->getL10N('federatedfilesharing'),
|
|
||||||
$server->getCloudIdManager()
|
|
||||||
);
|
|
||||||
$notification = new Notifications(
|
|
||||||
$addressHandler,
|
|
||||||
$server->getHTTPClientService(),
|
|
||||||
$server->query(\OCP\OCS\IDiscoveryService::class),
|
|
||||||
\OC::$server->getJobList(),
|
|
||||||
\OC::$server->getCloudFederationProviderManager(),
|
|
||||||
\OC::$server->getCloudFederationFactory()
|
|
||||||
);
|
|
||||||
return new RequestHandlerController(
|
|
||||||
$c->query('AppName'),
|
|
||||||
$server->getRequest(),
|
|
||||||
$this->getFederatedShareProvider(),
|
|
||||||
$server->getDatabaseConnection(),
|
|
||||||
$server->getShareManager(),
|
|
||||||
$notification,
|
|
||||||
$addressHandler,
|
|
||||||
$server->getUserManager(),
|
|
||||||
$server->getCloudIdManager(),
|
|
||||||
$server->getLogger(),
|
|
||||||
$server->getCloudFederationFactory(),
|
|
||||||
$server->getCloudFederationProviderManager()
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
// register events listeners
|
|
||||||
$eventDispatcher = $server->getEventDispatcher();
|
|
||||||
$manager = $server->getNotificationManager();
|
$manager = $server->getNotificationManager();
|
||||||
$federatedShareProvider = $this->getFederatedShareProvider();
|
|
||||||
|
|
||||||
$manager->registerNotifierService(Notifier::class);
|
$manager->registerNotifierService(Notifier::class);
|
||||||
|
|
||||||
$eventDispatcher->addListener(
|
|
||||||
'OCA\Files::loadAdditionalScripts',
|
|
||||||
function () use ($federatedShareProvider) {
|
|
||||||
if ($federatedShareProvider->isIncomingServer2serverShareEnabled()) {
|
|
||||||
\OCP\Util::addScript('federatedfilesharing', 'external');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* get instance of federated share provider
|
|
||||||
*
|
|
||||||
* @return FederatedShareProvider
|
|
||||||
*/
|
|
||||||
public function getFederatedShareProvider() {
|
|
||||||
if ($this->federatedShareProvider === null) {
|
|
||||||
$this->initFederatedShareProvider();
|
|
||||||
}
|
|
||||||
return $this->federatedShareProvider;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* initialize federated share provider
|
|
||||||
*/
|
|
||||||
protected function initFederatedShareProvider() {
|
|
||||||
$c = $this->getContainer();
|
|
||||||
$addressHandler = new \OCA\FederatedFileSharing\AddressHandler(
|
|
||||||
\OC::$server->getURLGenerator(),
|
|
||||||
\OC::$server->getL10N('federatedfilesharing'),
|
|
||||||
\OC::$server->getCloudIdManager()
|
|
||||||
);
|
|
||||||
$notifications = new \OCA\FederatedFileSharing\Notifications(
|
|
||||||
$addressHandler,
|
|
||||||
\OC::$server->getHTTPClientService(),
|
|
||||||
\OC::$server->query(\OCP\OCS\IDiscoveryService::class),
|
|
||||||
\OC::$server->getJobList(),
|
|
||||||
\OC::$server->getCloudFederationProviderManager(),
|
|
||||||
\OC::$server->getCloudFederationFactory()
|
|
||||||
);
|
|
||||||
$tokenHandler = new \OCA\FederatedFileSharing\TokenHandler(
|
|
||||||
\OC::$server->getSecureRandom()
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->federatedShareProvider = new \OCA\FederatedFileSharing\FederatedShareProvider(
|
|
||||||
\OC::$server->getDatabaseConnection(),
|
|
||||||
$addressHandler,
|
|
||||||
$notifications,
|
|
||||||
$tokenHandler,
|
|
||||||
\OC::$server->getL10N('federatedfilesharing'),
|
|
||||||
\OC::$server->getLogger(),
|
|
||||||
\OC::$server->getLazyRootFolder(),
|
|
||||||
\OC::$server->getConfig(),
|
|
||||||
\OC::$server->getUserManager(),
|
|
||||||
\OC::$server->getCloudIdManager(),
|
|
||||||
$c->query(IConfig::class),
|
|
||||||
\OC::$server->getCloudFederationProviderManager()
|
|
||||||
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,50 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
/**
|
||||||
|
* @copyright Copyright (c) 2020 Morris Jobke <hey@morrisjobke.de>
|
||||||
|
*
|
||||||
|
* @author Morris Jobke <hey@morrisjobke.de>
|
||||||
|
*
|
||||||
|
* @license GNU AGPL version 3 or any later version
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as
|
||||||
|
* published by the Free Software Foundation, either version 3 of the
|
||||||
|
* License, or (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
namespace OCA\FederatedFileSharing\Listeners;
|
||||||
|
|
||||||
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
|
use OCA\Files\Event\LoadAdditionalScriptsEvent;
|
||||||
|
use OCP\EventDispatcher\Event;
|
||||||
|
use OCP\EventDispatcher\IEventListener;
|
||||||
|
|
||||||
|
class LoadAdditionalScriptsListener implements IEventListener {
|
||||||
|
/** @var FederatedShareProvider */
|
||||||
|
protected $federatedShareProvider;
|
||||||
|
|
||||||
|
public function __construct(FederatedShareProvider $federatedShareProvider) {
|
||||||
|
$this->federatedShareProvider = $federatedShareProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function handle(Event $event): void {
|
||||||
|
if (!$event instanceof LoadAdditionalScriptsEvent) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($this->federatedShareProvider->isIncomingServer2serverShareEnabled()) {
|
||||||
|
\OCP\Util::addScript('federatedfilesharing', 'external');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -34,7 +34,6 @@
|
||||||
|
|
||||||
namespace OCA\Files_Sharing\ShareBackend;
|
namespace OCA\Files_Sharing\ShareBackend;
|
||||||
|
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCP\Share\IShare;
|
use OCP\Share\IShare;
|
||||||
|
|
||||||
|
@ -56,8 +55,7 @@ class File implements \OCP\Share_Backend_File_Dependent {
|
||||||
if ($federatedShareProvider) {
|
if ($federatedShareProvider) {
|
||||||
$this->federatedShareProvider = $federatedShareProvider;
|
$this->federatedShareProvider = $federatedShareProvider;
|
||||||
} else {
|
} else {
|
||||||
$federatedSharingApp = \OC::$server->query(Application::class);
|
$this->federatedShareProvider = \OC::$server->query(FederatedShareProvider::class);
|
||||||
$this->federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ return array(
|
||||||
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',
|
'OCA\\Provisioning_API\\Controller\\AppsController' => $baseDir . '/../lib/Controller/AppsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php',
|
'OCA\\Provisioning_API\\Controller\\GroupsController' => $baseDir . '/../lib/Controller/GroupsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
|
'OCA\\Provisioning_API\\Controller\\UsersController' => $baseDir . '/../lib/Controller/UsersController.php',
|
||||||
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => $baseDir . '/../lib/FederatedFileSharingFactory.php',
|
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => $baseDir . '/../lib/FederatedShareProviderFactory.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => $baseDir . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir . '/../lib/Middleware/ProvisioningApiMiddleware.php',
|
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => $baseDir . '/../lib/Middleware/ProvisioningApiMiddleware.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -27,7 +27,7 @@ class ComposerStaticInitProvisioning_API
|
||||||
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',
|
'OCA\\Provisioning_API\\Controller\\AppsController' => __DIR__ . '/..' . '/../lib/Controller/AppsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php',
|
'OCA\\Provisioning_API\\Controller\\GroupsController' => __DIR__ . '/..' . '/../lib/Controller/GroupsController.php',
|
||||||
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
|
'OCA\\Provisioning_API\\Controller\\UsersController' => __DIR__ . '/..' . '/../lib/Controller/UsersController.php',
|
||||||
'OCA\\Provisioning_API\\FederatedFileSharingFactory' => __DIR__ . '/..' . '/../lib/FederatedFileSharingFactory.php',
|
'OCA\\Provisioning_API\\FederatedShareProviderFactory' => __DIR__ . '/..' . '/../lib/FederatedShareProviderFactory.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
'OCA\\Provisioning_API\\Middleware\\Exceptions\\NotSubAdminException' => __DIR__ . '/..' . '/../lib/Middleware/Exceptions/NotSubAdminException.php',
|
||||||
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ProvisioningApiMiddleware.php',
|
'OCA\\Provisioning_API\\Middleware\\ProvisioningApiMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/ProvisioningApiMiddleware.php',
|
||||||
);
|
);
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace OCA\Provisioning_API\Controller;
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
use OC\Authentication\Token\RemoteWipe;
|
use OC\Authentication\Token\RemoteWipe;
|
||||||
use OC\HintException;
|
use OC\HintException;
|
||||||
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
use OCA\Provisioning_API\FederatedShareProviderFactory;
|
||||||
use OCA\Settings\Mailer\NewUserMailHelper;
|
use OCA\Settings\Mailer\NewUserMailHelper;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
@ -70,8 +70,8 @@ class UsersController extends AUserData {
|
||||||
protected $l10nFactory;
|
protected $l10nFactory;
|
||||||
/** @var NewUserMailHelper */
|
/** @var NewUserMailHelper */
|
||||||
private $newUserMailHelper;
|
private $newUserMailHelper;
|
||||||
/** @var FederatedFileSharingFactory */
|
/** @var FederatedShareProviderFactory */
|
||||||
private $federatedFileSharingFactory;
|
private $federatedShareProviderFactory;
|
||||||
/** @var ISecureRandom */
|
/** @var ISecureRandom */
|
||||||
private $secureRandom;
|
private $secureRandom;
|
||||||
/** @var RemoteWipe */
|
/** @var RemoteWipe */
|
||||||
|
@ -88,7 +88,7 @@ class UsersController extends AUserData {
|
||||||
ILogger $logger,
|
ILogger $logger,
|
||||||
IFactory $l10nFactory,
|
IFactory $l10nFactory,
|
||||||
NewUserMailHelper $newUserMailHelper,
|
NewUserMailHelper $newUserMailHelper,
|
||||||
FederatedFileSharingFactory $federatedFileSharingFactory,
|
FederatedShareProviderFactory $federatedShareProviderFactory,
|
||||||
ISecureRandom $secureRandom,
|
ISecureRandom $secureRandom,
|
||||||
RemoteWipe $remoteWipe) {
|
RemoteWipe $remoteWipe) {
|
||||||
parent::__construct($appName,
|
parent::__construct($appName,
|
||||||
|
@ -104,7 +104,7 @@ class UsersController extends AUserData {
|
||||||
$this->logger = $logger;
|
$this->logger = $logger;
|
||||||
$this->l10nFactory = $l10nFactory;
|
$this->l10nFactory = $l10nFactory;
|
||||||
$this->newUserMailHelper = $newUserMailHelper;
|
$this->newUserMailHelper = $newUserMailHelper;
|
||||||
$this->federatedFileSharingFactory = $federatedFileSharingFactory;
|
$this->federatedShareProviderFactory = $federatedShareProviderFactory;
|
||||||
$this->secureRandom = $secureRandom;
|
$this->secureRandom = $secureRandom;
|
||||||
$this->remoteWipe = $remoteWipe;
|
$this->remoteWipe = $remoteWipe;
|
||||||
}
|
}
|
||||||
|
@ -418,8 +418,7 @@ class UsersController extends AUserData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
||||||
$federatedFileSharing = $this->federatedFileSharingFactory->get();
|
$shareProvider = $this->federatedShareProviderFactory->get();
|
||||||
$shareProvider = $federatedFileSharing->getFederatedShareProvider();
|
|
||||||
if ($shareProvider->isLookupServerUploadEnabled()) {
|
if ($shareProvider->isLookupServerUploadEnabled()) {
|
||||||
$permittedFields[] = AccountManager::PROPERTY_PHONE;
|
$permittedFields[] = AccountManager::PROPERTY_PHONE;
|
||||||
$permittedFields[] = AccountManager::PROPERTY_ADDRESS;
|
$permittedFields[] = AccountManager::PROPERTY_ADDRESS;
|
||||||
|
@ -473,8 +472,7 @@ class UsersController extends AUserData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
||||||
$federatedFileSharing = \OC::$server->query(\OCA\FederatedFileSharing\AppInfo\Application::class);
|
$shareProvider = $this->federatedShareProviderFactory->get();
|
||||||
$shareProvider = $federatedFileSharing->getFederatedShareProvider();
|
|
||||||
if ($shareProvider->isLookupServerUploadEnabled()) {
|
if ($shareProvider->isLookupServerUploadEnabled()) {
|
||||||
$permittedFields[] = AccountManager::PROPERTY_PHONE;
|
$permittedFields[] = AccountManager::PROPERTY_PHONE;
|
||||||
$permittedFields[] = AccountManager::PROPERTY_ADDRESS;
|
$permittedFields[] = AccountManager::PROPERTY_ADDRESS;
|
||||||
|
|
|
@ -25,10 +25,10 @@ declare(strict_types=1);
|
||||||
|
|
||||||
namespace OCA\Provisioning_API;
|
namespace OCA\Provisioning_API;
|
||||||
|
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCP\IServerContainer;
|
use OCP\IServerContainer;
|
||||||
|
|
||||||
class FederatedFileSharingFactory {
|
class FederatedShareProviderFactory {
|
||||||
|
|
||||||
/** @var IServerContainer */
|
/** @var IServerContainer */
|
||||||
private $serverContainer;
|
private $serverContainer;
|
||||||
|
@ -37,7 +37,7 @@ class FederatedFileSharingFactory {
|
||||||
$this->serverContainer = $serverContainer;
|
$this->serverContainer = $serverContainer;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function get(): Application {
|
public function get(): FederatedShareProvider {
|
||||||
return $this->serverContainer->query(Application::class);
|
return $this->serverContainer->query(FederatedShareProvider::class);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -42,10 +42,9 @@ use OC\Accounts\AccountManager;
|
||||||
use OC\Authentication\Token\RemoteWipe;
|
use OC\Authentication\Token\RemoteWipe;
|
||||||
use OC\Group\Manager;
|
use OC\Group\Manager;
|
||||||
use OC\SubAdmin;
|
use OC\SubAdmin;
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
|
||||||
use OCA\FederatedFileSharing\FederatedShareProvider;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCA\Provisioning_API\Controller\UsersController;
|
use OCA\Provisioning_API\Controller\UsersController;
|
||||||
use OCA\Provisioning_API\FederatedFileSharingFactory;
|
use OCA\Provisioning_API\FederatedShareProviderFactory;
|
||||||
use OCA\Settings\Mailer\NewUserMailHelper;
|
use OCA\Settings\Mailer\NewUserMailHelper;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\DataResponse;
|
use OCP\AppFramework\Http\DataResponse;
|
||||||
|
@ -89,8 +88,8 @@ class UsersControllerTest extends TestCase {
|
||||||
private $l10nFactory;
|
private $l10nFactory;
|
||||||
/** @var NewUserMailHelper|PHPUnit_Framework_MockObject_MockObject */
|
/** @var NewUserMailHelper|PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $newUserMailHelper;
|
private $newUserMailHelper;
|
||||||
/** @var FederatedFileSharingFactory|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var FederatedShareProviderFactory|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $federatedFileSharingFactory;
|
private $federatedShareProviderFactory;
|
||||||
/** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
|
/** @var ISecureRandom|\PHPUnit_Framework_MockObject_MockObject */
|
||||||
private $secureRandom;
|
private $secureRandom;
|
||||||
/** @var RemoteWipe|MockObject */
|
/** @var RemoteWipe|MockObject */
|
||||||
|
@ -109,7 +108,7 @@ class UsersControllerTest extends TestCase {
|
||||||
$this->accountManager = $this->createMock(AccountManager::class);
|
$this->accountManager = $this->createMock(AccountManager::class);
|
||||||
$this->l10nFactory = $this->createMock(IFactory::class);
|
$this->l10nFactory = $this->createMock(IFactory::class);
|
||||||
$this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
|
$this->newUserMailHelper = $this->createMock(NewUserMailHelper::class);
|
||||||
$this->federatedFileSharingFactory = $this->createMock(FederatedFileSharingFactory::class);
|
$this->federatedShareProviderFactory = $this->createMock(FederatedShareProviderFactory::class);
|
||||||
$this->secureRandom = $this->createMock(ISecureRandom::class);
|
$this->secureRandom = $this->createMock(ISecureRandom::class);
|
||||||
$this->remoteWipe = $this->createMock(RemoteWipe::class);
|
$this->remoteWipe = $this->createMock(RemoteWipe::class);
|
||||||
|
|
||||||
|
@ -126,7 +125,7 @@ class UsersControllerTest extends TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->l10nFactory,
|
$this->l10nFactory,
|
||||||
$this->newUserMailHelper,
|
$this->newUserMailHelper,
|
||||||
$this->federatedFileSharingFactory,
|
$this->federatedShareProviderFactory,
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->remoteWipe,
|
$this->remoteWipe,
|
||||||
])
|
])
|
||||||
|
@ -388,7 +387,7 @@ class UsersControllerTest extends TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->l10nFactory,
|
$this->l10nFactory,
|
||||||
$this->newUserMailHelper,
|
$this->newUserMailHelper,
|
||||||
$this->federatedFileSharingFactory,
|
$this->federatedShareProviderFactory,
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->remoteWipe
|
$this->remoteWipe
|
||||||
])
|
])
|
||||||
|
@ -3124,7 +3123,7 @@ class UsersControllerTest extends TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->l10nFactory,
|
$this->l10nFactory,
|
||||||
$this->newUserMailHelper,
|
$this->newUserMailHelper,
|
||||||
$this->federatedFileSharingFactory,
|
$this->federatedShareProviderFactory,
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->remoteWipe,
|
$this->remoteWipe,
|
||||||
])
|
])
|
||||||
|
@ -3188,7 +3187,7 @@ class UsersControllerTest extends TestCase {
|
||||||
$this->logger,
|
$this->logger,
|
||||||
$this->l10nFactory,
|
$this->l10nFactory,
|
||||||
$this->newUserMailHelper,
|
$this->newUserMailHelper,
|
||||||
$this->federatedFileSharingFactory,
|
$this->federatedShareProviderFactory,
|
||||||
$this->secureRandom,
|
$this->secureRandom,
|
||||||
$this->remoteWipe,
|
$this->remoteWipe,
|
||||||
])
|
])
|
||||||
|
@ -3555,14 +3554,9 @@ class UsersControllerTest extends TestCase {
|
||||||
$shareprovider = $this->createMock(FederatedShareProvider::class);
|
$shareprovider = $this->createMock(FederatedShareProvider::class);
|
||||||
$shareprovider->method('isLookupServerUploadEnabled')->willReturn(true);
|
$shareprovider->method('isLookupServerUploadEnabled')->willReturn(true);
|
||||||
|
|
||||||
$federatedFileSharing = $this->createMock(Application::class);
|
$this->federatedShareProviderFactory
|
||||||
$federatedFileSharing
|
|
||||||
->method('getFederatedShareProvider')
|
|
||||||
->willReturn($shareprovider);
|
|
||||||
|
|
||||||
$this->federatedFileSharingFactory
|
|
||||||
->method('get')
|
->method('get')
|
||||||
->willReturn($federatedFileSharing);
|
->willReturn($shareprovider);
|
||||||
|
|
||||||
$expectedResp = new DataResponse($expected);
|
$expectedResp = new DataResponse($expected);
|
||||||
$this->assertEquals($expectedResp, $this->api->getEditableFields());
|
$this->assertEquals($expectedResp, $this->api->getEditableFields());
|
||||||
|
|
|
@ -36,6 +36,7 @@ use OC\AppFramework\Http;
|
||||||
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
|
use OC\Encryption\Exceptions\ModuleDoesNotExistsException;
|
||||||
use OC\ForbiddenException;
|
use OC\ForbiddenException;
|
||||||
use OC\Security\IdentityProof\Manager;
|
use OC\Security\IdentityProof\Manager;
|
||||||
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCA\Settings\BackgroundJobs\VerifyUserData;
|
use OCA\Settings\BackgroundJobs\VerifyUserData;
|
||||||
use OCA\User_LDAP\User_Proxy;
|
use OCA\User_LDAP\User_Proxy;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
|
@ -362,8 +363,7 @@ class UsersController extends Controller {
|
||||||
$data[AccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
|
$data[AccountManager::PROPERTY_EMAIL] = ['value' => $email, 'scope' => $emailScope];
|
||||||
}
|
}
|
||||||
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
if ($this->appManager->isEnabledForUser('federatedfilesharing')) {
|
||||||
$federatedFileSharing = new \OCA\FederatedFileSharing\AppInfo\Application();
|
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
|
||||||
$shareProvider = $federatedFileSharing->getFederatedShareProvider();
|
|
||||||
if ($shareProvider->isLookupServerUploadEnabled()) {
|
if ($shareProvider->isLookupServerUploadEnabled()) {
|
||||||
$data[AccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
|
$data[AccountManager::PROPERTY_WEBSITE] = ['value' => $website, 'scope' => $websiteScope];
|
||||||
$data[AccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
|
$data[AccountManager::PROPERTY_ADDRESS] = ['value' => $address, 'scope' => $addressScope];
|
||||||
|
|
|
@ -32,7 +32,7 @@
|
||||||
namespace OCA\Settings\Settings\Personal;
|
namespace OCA\Settings\Settings\Personal;
|
||||||
|
|
||||||
use OC\Accounts\AccountManager;
|
use OC\Accounts\AccountManager;
|
||||||
use OCA\FederatedFileSharing\AppInfo\Application;
|
use OCA\FederatedFileSharing\FederatedShareProvider;
|
||||||
use OCP\App\IAppManager;
|
use OCP\App\IAppManager;
|
||||||
use OCP\AppFramework\Http\TemplateResponse;
|
use OCP\AppFramework\Http\TemplateResponse;
|
||||||
use OCP\Files\FileInfo;
|
use OCP\Files\FileInfo;
|
||||||
|
@ -96,8 +96,8 @@ class PersonalInfo implements ISettings {
|
||||||
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
|
$federatedFileSharingEnabled = $this->appManager->isEnabledForUser('federatedfilesharing');
|
||||||
$lookupServerUploadEnabled = false;
|
$lookupServerUploadEnabled = false;
|
||||||
if ($federatedFileSharingEnabled) {
|
if ($federatedFileSharingEnabled) {
|
||||||
$federatedFileSharing = \OC::$server->query(Application::class);
|
/** @var FederatedShareProvider $shareProvider */
|
||||||
$shareProvider = $federatedFileSharing->getFederatedShareProvider();
|
$shareProvider = \OC::$server->query(FederatedShareProvider::class);
|
||||||
$lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
|
$lookupServerUploadEnabled = $shareProvider->isLookupServerUploadEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue