]> source.dussan.org Git - nextcloud-server.git/commitdiff
Use automatic DI injection for UpdateLookupServer
authorJoas Schilling <coding@schilljs.com>
Wed, 10 May 2017 07:44:02 +0000 (09:44 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 10 May 2017 07:44:02 +0000 (09:44 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/lookup_server_connector/appinfo/app.php
apps/lookup_server_connector/lib/UpdateLookupServer.php

index f0d624d5f3aa42dbe8c960324adbfb0e5df274cd..28e7bea192ae8b38d4ef0e0fb5a160ba0d224331 100644 (file)
 $dispatcher = \OC::$server->getEventDispatcher();
 
 $dispatcher->addListener('OC\AccountManager::userUpdated', function(\Symfony\Component\EventDispatcher\GenericEvent $event) {
+       /** @var \OCP\IUser $user */
        $user = $event->getSubject();
 
-       $keyManager = new \OC\Security\IdentityProof\Manager(
-               \OC::$server->getAppDataDir('identityproof'),
-               \OC::$server->getCrypto()
-       );
-
-       $config = \OC::$server->getConfig();
-       $lookupServer = $config->getSystemValue('lookup_server', '');
-
-       $updateLookupServer = new \OCA\LookupServerConnector\UpdateLookupServer(
-               new \OC\Accounts\AccountManager(
-                       \OC::$server->getDatabaseConnection(),
-                       \OC::$server->getEventDispatcher(),
-                       \OC::$server->getJobList()
-               ),
-               \OC::$server->getHTTPClientService(),
-               new \OC\Security\IdentityProof\Signer(
-                       $keyManager,
-                       new \OC\AppFramework\Utility\TimeFactory(),
-                       \OC::$server->getUserManager()
-               ),
-               \OC::$server->getJobList(),
-               $lookupServer
-       );
+       /** @var \OCA\LookupServerConnector\UpdateLookupServer $updateLookupServer */
+       $updateLookupServer = \OC::$server->query(\OCA\LookupServerConnector\UpdateLookupServer::class);
        $updateLookupServer->userUpdated($user);
 });
index 3a7c2fa7236ff1c4ee8f11639a86151bde990e7f..ae8fcbd67cae73ee4009dc302b7fadf09fcd484e 100644 (file)
@@ -27,6 +27,7 @@ use OC\Security\IdentityProof\Signer;
 use OCA\LookupServerConnector\BackgroundJobs\RetryJob;
 use OCP\BackgroundJob\IJobList;
 use OCP\Http\Client\IClientService;
+use OCP\IConfig;
 use OCP\IUser;
 
 /**
@@ -44,27 +45,26 @@ class UpdateLookupServer {
        /** @var IJobList */
        private $jobList;
        /** @var string URL point to lookup server */
-       private $lookupServer = 'https://lookup.nextcloud.com';
+       private $lookupServer;
 
        /**
         * @param AccountManager $accountManager
         * @param IClientService $clientService
         * @param Signer $signer
         * @param IJobList $jobList
-        * @param string $lookupServer if nothing is given we use the default lookup server
+        * @param IConfig $config
         */
        public function __construct(AccountManager $accountManager,
                                                                IClientService $clientService,
                                                                Signer $signer,
                                                                IJobList $jobList,
-                                                               $lookupServer = '') {
+                                                               IConfig $config) {
                $this->accountManager = $accountManager;
                $this->clientService = $clientService;
                $this->signer = $signer;
                $this->jobList = $jobList;
-               if ($lookupServer !== '') {
-                       $this->lookupServer = $lookupServer;
-               }
+
+               $this->lookupServer = $config->getSystemValue('lookup_server', 'https://lookup.nextcloud.com');
                $this->lookupServer = rtrim($this->lookupServer, '/');
                $this->lookupServer .= '/users';
        }