'OCA\\DAV\\Direct\\DirectHome' => $baseDir . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => $baseDir . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => $baseDir . '/../lib/Direct/ServerFactory.php',
+ 'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => $baseDir . '/../lib/Events/SabrePluginAuthInitEvent.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => $baseDir . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => $baseDir . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => $baseDir . '/../lib/Files/FileSearchBackend.php',
'OCA\\DAV\\Direct\\DirectHome' => __DIR__ . '/..' . '/../lib/Direct/DirectHome.php',
'OCA\\DAV\\Direct\\Server' => __DIR__ . '/..' . '/../lib/Direct/Server.php',
'OCA\\DAV\\Direct\\ServerFactory' => __DIR__ . '/..' . '/../lib/Direct/ServerFactory.php',
+ 'OCA\\DAV\\Events\\SabrePluginAuthInitEvent' => __DIR__ . '/..' . '/../lib/Events/SabrePluginAuthInitEvent.php',
'OCA\\DAV\\Exception\\UnsupportedLimitOnInitialSyncException' => __DIR__ . '/..' . '/../lib/Exception/UnsupportedLimitOnInitialSyncException.php',
'OCA\\DAV\\Files\\BrowserErrorPagePlugin' => __DIR__ . '/..' . '/../lib/Files/BrowserErrorPagePlugin.php',
'OCA\\DAV\\Files\\FileSearchBackend' => __DIR__ . '/..' . '/../lib/Files/FileSearchBackend.php',
use OCA\DAV\Connector\Sabre\BlockLegacyClientPlugin;
use OCA\DAV\Connector\Sabre\CachingTree;
use OCA\DAV\Connector\Sabre\DavAclPlugin;
+use OCA\DAV\Events\SabrePluginAuthInitEvent;
use OCA\DAV\RootCollection;
-use OCP\SabrePluginEvent;
+use OCP\EventDispatcher\IEventDispatcher;
use Sabre\DAV\Auth\Plugin;
use Sabre\VObject\ITip\Message;
public function __construct() {
$baseUri = \OC::$WEBROOT . '/remote.php/dav/';
$logger = \OC::$server->getLogger();
- $dispatcher = \OC::$server->getEventDispatcher();
+ /** @var IEventDispatcher $dispatcher */
+ $dispatcher = \OC::$server->query(IEventDispatcher::class);
$root = new RootCollection();
$this->server = new \OCA\DAV\Connector\Sabre\Server(new CachingTree($root));
});
// allow setup of additional auth backends
- $event = new SabrePluginEvent($this->server);
- $dispatcher->dispatch('OCA\DAV\Connector\Sabre::authInit', $event);
+ $event = new SabrePluginAuthInitEvent($this->server);
+ $dispatcher->dispatchTyped($event);
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\ExceptionLoggerPlugin('webdav', $logger));
$this->server->addPlugin(new \OCA\DAV\Connector\Sabre\LockPlugin());
--- /dev/null
+<?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\DAV\Events;
+
+use OCP\EventDispatcher\Event;
+use Sabre\DAV\Server;
+
+/**
+ * This event is triggered during the setup of the SabreDAV server to allow the
+ * registration of additional authentication backends.
+ *
+ * @since 20.0.0
+ */
+class SabrePluginAuthInitEvent extends Event {
+
+ /** @var Server */
+ private $server;
+
+ /**
+ * @since 20.0.0
+ */
+ public function __construct(Server $server) {
+ $this->server = $server;
+ }
+
+ /**
+ * @since 20.0.0
+ */
+ public function getServer(): Server {
+ return $this->server;
+ }
+}
'OCA\\FederatedFileSharing\\BackgroundJob\\RetryJob' => $baseDir . '/../lib/BackgroundJob/RetryJob.php',
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => $baseDir . '/../lib/Controller/MountPublicLinkController.php',
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => $baseDir . '/../lib/Controller/RequestHandlerController.php',
+ 'OCA\\FederatedFileSharing\\Events\\FederatedShareAddedEvent' => $baseDir . '/../lib/Events/FederatedShareAddedEvent.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\\BackgroundJob\\RetryJob' => __DIR__ . '/..' . '/../lib/BackgroundJob/RetryJob.php',
'OCA\\FederatedFileSharing\\Controller\\MountPublicLinkController' => __DIR__ . '/..' . '/../lib/Controller/MountPublicLinkController.php',
'OCA\\FederatedFileSharing\\Controller\\RequestHandlerController' => __DIR__ . '/..' . '/../lib/Controller/RequestHandlerController.php',
+ 'OCA\\FederatedFileSharing\\Events\\FederatedShareAddedEvent' => __DIR__ . '/..' . '/../lib/Events/FederatedShareAddedEvent.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',
--- /dev/null
+<?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\Events;
+
+use OCP\EventDispatcher\Event;
+
+/**
+ * This event is triggered when a federated share is successfully added
+ *
+ * @since 20.0.0
+ */
+class FederatedShareAddedEvent extends Event {
+
+ /** @var string */
+ private $remote;
+
+ /**
+ * @since 20.0.0
+ */
+ public function __construct(string $remote) {
+ $this->remote = $remote;
+ }
+
+ /**
+ * @since 20.0.0
+ */
+ public function getRemote(): string {
+ return $this->remote;
+ }
+}
namespace OCA\FederatedFileSharing;
+use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
use OCP\AppFramework\Http;
use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
/** @var ICloudFederationFactory */
private $cloudFederationFactory;
- /**
- * @param AddressHandler $addressHandler
- * @param IClientService $httpClientService
- * @param IDiscoveryService $discoveryService
- * @param IJobList $jobList
- * @param ICloudFederationProviderManager $federationProviderManager
- * @param ICloudFederationFactory $cloudFederationFactory
- */
+ /** @var IEventDispatcher */
+ private $eventDispatcher;
+
public function __construct(
AddressHandler $addressHandler,
IClientService $httpClientService,
IDiscoveryService $discoveryService,
IJobList $jobList,
ICloudFederationProviderManager $federationProviderManager,
- ICloudFederationFactory $cloudFederationFactory
+ ICloudFederationFactory $cloudFederationFactory,
+ IEventDispatcher $eventDispatcher
) {
$this->addressHandler = $addressHandler;
$this->httpClientService = $httpClientService;
$this->jobList = $jobList;
$this->federationProviderManager = $federationProviderManager;
$this->cloudFederationFactory = $cloudFederationFactory;
+ $this->eventDispatcher = $eventDispatcher;
}
/**
$ocsSuccess = $ocsStatus && ($status['ocs']['meta']['statuscode'] === 100 || $status['ocs']['meta']['statuscode'] === 200);
if ($result['success'] && (!$ocsStatus ||$ocsSuccess)) {
- \OC_Hook::emit('OCP\Share', 'federated_share_added', ['server' => $remote]);
+ $event = new FederatedShareAddedEvent($remote);
+ $this->eventDispatcher->dispatchTyped($event);
return true;
}
}
use OCP\Activity\IManager as IActivityManager;
use OCP\App\IAppManager;
use OCP\Constants;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\Exceptions\ActionNotSupportedException;
use OCP\Federation\Exceptions\AuthenticationFailedException;
use OCP\Federation\Exceptions\BadRequestException;
\OC::$server->getCloudFederationFactory(),
\OC::$server->getGroupManager(),
\OC::$server->getUserManager(),
- $shareWith
+ $shareWith,
+ \OC::$server->query(IEventDispatcher::class)
);
try {
use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Notifications;
use OCP\BackgroundJob\IJobList;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
/** @var ICloudFederationFactory|\PHPUnit_Framework_MockObject_MockObject */
private $cloudFederationFactory;
+ /** @var IEventDispatcher|\PHPUnit_Framework_MockObject_MockObject */
+ private $eventDispatcher;
+
protected function setUp(): void {
parent::setUp();
->disableOriginalConstructor()->getMock();
$this->cloudFederationProviderManager = $this->createMock(ICloudFederationProviderManager::class);
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
}
/**
$this->discoveryService,
$this->jobList,
$this->cloudFederationProviderManager,
- $this->cloudFederationFactory
+ $this->cloudFederationFactory,
+ $this->eventDispatcher
);
} else {
$instance = $this->getMockBuilder('OCA\FederatedFileSharing\Notifications')
$this->discoveryService,
$this->jobList,
$this->cloudFederationProviderManager,
- $this->cloudFederationFactory
+ $this->cloudFederationFactory,
+ $this->eventDispatcher
]
)->setMethods($mockedMethods)->getMock();
}
+++ /dev/null
-<?php
-/**
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- *
- * @author Björn Schießle <bjoern@schiessle.org>
- * @author Christoph Wurst <christoph@winzerhof-wurst.at>
- *
- * @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/>
- *
- */
-
-namespace OCA\Federation\AppInfo;
-
-/** @var Application $app */
-$app = \OC::$server->query(Application::class);
-$app->registerHooks();
'OCA\\Federation\\DAV\\FedAuth' => $baseDir . '/../lib/DAV/FedAuth.php',
'OCA\\Federation\\DbHandler' => $baseDir . '/../lib/DbHandler.php',
'OCA\\Federation\\Hooks' => $baseDir . '/../lib/Hooks.php',
+ 'OCA\\Federation\\Listener\\FederatedShareAddedListener' => $baseDir . '/../lib/Listeners/FederatedShareAddedListener.php',
+ 'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => $baseDir . '/../lib/Listeners/SabrePluginAuthInitListener.php',
'OCA\\Federation\\Middleware\\AddServerMiddleware' => $baseDir . '/../lib/Middleware/AddServerMiddleware.php',
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => $baseDir . '/../lib/Migration/Version1010Date20200630191302.php',
'OCA\\Federation\\Settings\\Admin' => $baseDir . '/../lib/Settings/Admin.php',
'OCA\\Federation\\DAV\\FedAuth' => __DIR__ . '/..' . '/../lib/DAV/FedAuth.php',
'OCA\\Federation\\DbHandler' => __DIR__ . '/..' . '/../lib/DbHandler.php',
'OCA\\Federation\\Hooks' => __DIR__ . '/..' . '/../lib/Hooks.php',
+ 'OCA\\Federation\\Listener\\FederatedShareAddedListener' => __DIR__ . '/..' . '/../lib/Listeners/FederatedShareAddedListener.php',
+ 'OCA\\Federation\\Listener\\SabrePluginAuthInitListener' => __DIR__ . '/..' . '/../lib/Listeners/SabrePluginAuthInitListener.php',
'OCA\\Federation\\Middleware\\AddServerMiddleware' => __DIR__ . '/..' . '/../lib/Middleware/AddServerMiddleware.php',
'OCA\\Federation\\Migration\\Version1010Date20200630191302' => __DIR__ . '/..' . '/../lib/Migration/Version1010Date20200630191302.php',
'OCA\\Federation\\Settings\\Admin' => __DIR__ . '/..' . '/../lib/Settings/Admin.php',
namespace OCA\Federation\AppInfo;
-use OCA\Federation\DAV\FedAuth;
-use OCA\Federation\Hooks;
+use OCA\DAV\Events\SabrePluginAuthInitEvent;
+use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
+use OCA\Federation\Listener\FederatedShareAddedListener;
+use OCA\Federation\Listener\SabrePluginAuthInitListener;
use OCA\Federation\Middleware\AddServerMiddleware;
use OCP\AppFramework\App;
-use OCP\SabrePluginEvent;
-use OCP\Share;
-use OCP\Util;
-use Sabre\DAV\Auth\Plugin;
-use Sabre\DAV\Server;
+use OCP\AppFramework\Bootstrap\IBootContext;
+use OCP\AppFramework\Bootstrap\IBootstrap;
+use OCP\AppFramework\Bootstrap\IRegistrationContext;
-class Application extends App {
+class Application extends App implements IBootstrap {
/**
* @param array $urlParams
*/
public function __construct($urlParams = []) {
parent::__construct('federation', $urlParams);
- $this->registerMiddleware();
}
- private function registerMiddleware() {
- $container = $this->getContainer();
- $container->registerAlias('AddServerMiddleware', AddServerMiddleware::class);
- $container->registerMiddleWare('AddServerMiddleware');
- }
+ public function register(IRegistrationContext $context): void {
+ $context->registerMiddleware(AddServerMiddleware::class);
- /**
- * listen to federated_share_added hooks to auto-add new servers to the
- * list of trusted servers.
- */
- public function registerHooks() {
- $container = $this->getContainer();
- $hooksManager = $container->query(Hooks::class);
-
- Util::connectHook(
- Share::class,
- 'federated_share_added',
- $hooksManager,
- 'addServerHook'
- );
+ $context->registerEventListener(FederatedShareAddedEvent::class, FederatedShareAddedListener::class);
+ $context->registerEventListener(SabrePluginAuthInitEvent::class, SabrePluginAuthInitListener::class);
+ }
- $dispatcher = $container->getServer()->getEventDispatcher();
- $dispatcher->addListener('OCA\DAV\Connector\Sabre::authInit', function ($event) use ($container) {
- if ($event instanceof SabrePluginEvent) {
- $server = $event->getServer();
- if ($server instanceof Server) {
- $authPlugin = $server->getPlugin('auth');
- if ($authPlugin instanceof Plugin) {
- $authPlugin->addBackend($container->query(FedAuth::class));
- }
- }
- }
- });
+ public function boot(IBootContext $context): void {
}
}
--- /dev/null
+<?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\Federation\Listener;
+
+use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
+use OCA\Federation\TrustedServers;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+
+/**
+ * Automatically add new servers to the list of trusted servers.
+ *
+ * @since 20.0.0
+ */
+class FederatedShareAddedListener implements IEventListener {
+ /** @var TrustedServers */
+ private $trustedServers;
+
+ public function __construct(TrustedServers $trustedServers) {
+ $this->trustedServers = $trustedServers;
+ }
+
+ public function handle(Event $event): void {
+ if (!($event instanceof FederatedShareAddedEvent)) {
+ return;
+ }
+
+ $server = $event->getRemote();
+ if (
+ $this->trustedServers->getAutoAddServers() === true &&
+ $this->trustedServers->isTrustedServer($server) === false
+ ) {
+ $this->trustedServers->addServer($server);
+ }
+ }
+}
--- /dev/null
+<?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\Federation\Listener;
+
+use OCA\DAV\Events\SabrePluginAuthInitEvent;
+use OCA\Federation\DAV\FedAuth;
+use OCP\EventDispatcher\Event;
+use OCP\EventDispatcher\IEventListener;
+use Sabre\DAV\Auth\Plugin;
+
+/**
+ * @since 20.0.0
+ */
+class SabrePluginAuthInitListener implements IEventListener {
+ /** @var FedAuth */
+ private $fedAuth;
+
+ public function __construct(FedAuth $fedAuth) {
+ $this->fedAuth = $fedAuth;
+ }
+
+ public function handle(Event $event): void {
+ if (!($event instanceof SabrePluginAuthInitEvent)) {
+ return;
+ }
+
+ $server = $event->getServer();
+ $authPlugin = $server->getPlugin('auth');
+ if ($authPlugin instanceof Plugin) {
+ $authPlugin->addBackend($this->fedAuth);
+ }
+ }
+}
$server->getCloudFederationFactory(),
$server->getGroupManager(),
$server->getUserManager(),
- $uid
+ $uid,
+ $server->query(IEventDispatcher::class)
);
});
namespace OCA\Files_Sharing\External;
use OC\Files\Filesystem;
+use OCA\FederatedFileSharing\Events\FederatedShareAddedEvent;
use OCA\Files_Sharing\Helper;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Files;
class Manager {
public const STORAGE = '\OCA\Files_Sharing\External\Storage';
- /**
- * @var string
- */
+ /** @var string */
private $uid;
- /**
- * @var IDBConnection
- */
+ /** @var IDBConnection */
private $connection;
- /**
- * @var \OC\Files\Mount\Manager
- */
+ /** @var \OC\Files\Mount\Manager */
private $mountManager;
- /**
- * @var IStorageFactory
- */
+ /** @var IStorageFactory */
private $storageLoader;
- /**
- * @var IClientService
- */
+ /** @var IClientService */
private $clientService;
- /**
- * @var IManager
- */
+ /** @var IManager */
private $notificationManager;
- /**
- * @var IDiscoveryService
- */
+ /** @var IDiscoveryService */
private $discoveryService;
/** @var ICloudFederationProviderManager */
/** @var IUserManager */
private $userManager;
- /**
- * @param IDBConnection $connection
- * @param \OC\Files\Mount\Manager $mountManager
- * @param IStorageFactory $storageLoader
- * @param IClientService $clientService
- * @param IManager $notificationManager
- * @param IDiscoveryService $discoveryService
- * @param ICloudFederationProviderManager $cloudFederationProviderManager
- * @param ICloudFederationFactory $cloudFederationFactory
- * @param IGroupManager $groupManager
- * @param IUserManager $userManager
- * @param string $uid
- */
+ /** @var IEventDispatcher */
+ private $eventDispatcher;
+
public function __construct(IDBConnection $connection,
\OC\Files\Mount\Manager $mountManager,
IStorageFactory $storageLoader,
ICloudFederationFactory $cloudFederationFactory,
IGroupManager $groupManager,
IUserManager $userManager,
- $uid) {
+ string $uid,
+ IEventDispatcher $eventDispatcher) {
$this->connection = $connection;
$this->mountManager = $mountManager;
$this->storageLoader = $storageLoader;
$this->cloudFederationFactory = $cloudFederationFactory;
$this->groupManager = $groupManager;
$this->userManager = $userManager;
+ $this->eventDispatcher = $eventDispatcher;
}
/**
}
if ($userShareAccepted === true) {
$this->sendFeedbackToRemote($share['remote'], $share['share_token'], $share['remote_id'], 'accept');
- \OC_Hook::emit(Share::class, 'federated_share_added', ['server' => $share['remote']]);
+ $event = new FederatedShareAddedEvent($share['remote']);
+ $this->eventDispatcher->dispatchTyped($event);
$result = true;
}
}
namespace OCA\Files_Sharing;
use OC\Files\Filesystem;
+use OCP\EventDispatcher\IEventDispatcher;
class Hooks {
public static function deleteUser($params) {
\OC::$server->getCloudFederationFactory(),
\OC::$server->getGroupManager(),
\OC::$server->getUserManager(),
- $params['uid']);
+ $params['uid'],
+ \OC::$server->query(IEventDispatcher::class)
+ );
$manager->removeUserShares($params['uid']);
}
use OCA\Files_Sharing\External\Manager;
use OCA\Files_Sharing\External\MountProvider;
use OCA\Files_Sharing\Tests\TestCase;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\Federation\ICloudFederationFactory;
use OCP\Federation\ICloudFederationProviderManager;
use OCP\Http\Client\IClientService;
*/
private $user;
private $testMountProvider;
+ /** @var IEventDispatcher|\PHPUnit\Framework\MockObject\MockObject */
+ private $eventDispatcher;
protected function setUp(): void {
parent::setUp();
$this->cloudFederationFactory = $this->createMock(ICloudFederationFactory::class);
$this->groupManager = $this->createMock(IGroupManager::class);
$this->userManager = $this->createMock(IUserManager::class);
+ $this->eventDispatcher = $this->createMock(IEventDispatcher::class);
$this->manager = $this->getMockBuilder(Manager::class)
->setConstructorArgs(
$this->cloudFederationFactory,
$this->groupManager,
$this->userManager,
- $this->uid
+ $this->uid,
+ $this->eventDispatcher,
]
)->setMethods(['tryOCMEndPoint'])->getMock();
use OCA\ShareByMail\Settings\SettingsManager;
use OCA\ShareByMail\ShareByMailProvider;
use OCP\Defaults;
+use OCP\EventDispatcher\IEventDispatcher;
use OCP\IServerContainer;
use OCP\Share\IProviderFactory;
use OCP\Share\IShare;
$this->serverContainer->query(\OCP\OCS\IDiscoveryService::class),
$this->serverContainer->getJobList(),
\OC::$server->getCloudFederationProviderManager(),
- \OC::$server->getCloudFederationFactory()
+ \OC::$server->getCloudFederationFactory(),
+ $this->serverContainer->query(IEventDispatcher::class)
);
$tokenHandler = new TokenHandler(
$this->serverContainer->getSecureRandom()