]> source.dussan.org Git - nextcloud-server.git/commitdiff
Add missing parent::__construct() calls to Jobs
authorJoas Schilling <coding@schilljs.com>
Mon, 14 Dec 2020 15:35:12 +0000 (16:35 +0100)
committerJoas Schilling <coding@schilljs.com>
Mon, 14 Dec 2020 15:35:12 +0000 (16:35 +0100)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
apps/federation/lib/BackgroundJob/GetSharedSecret.php
apps/federation/lib/BackgroundJob/RequestSharedSecret.php
apps/settings/lib/BackgroundJobs/VerifyUserData.php

index 4949e5794b4f29c452850fb803b44a60d8f65cb2..14d86d4b44403605ee91d4ffa312c3f9e98091c2 100644 (file)
@@ -29,6 +29,7 @@ namespace OCA\FederatedFileSharing\BackgroundJob;
 
 use OCA\FederatedFileSharing\AddressHandler;
 use OCA\FederatedFileSharing\Notifications;
+use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\BackgroundJob\IJobList;
 use OCP\BackgroundJob\Job;
 use OCP\ILogger;
@@ -55,29 +56,11 @@ class RetryJob extends Job {
        /** @var int how much time should be between two tries (10 minutes) */
        private $interval = 600;
 
-       /**
-        * UnShare constructor.
-        *
-        * @param Notifications $notifications
-        */
-       public function __construct(Notifications $notifications = null) {
-               if ($notifications) {
-                       $this->notifications = $notifications;
-               } else {
-                       $addressHandler = new AddressHandler(
-                               \OC::$server->getURLGenerator(),
-                               \OC::$server->getL10N('federatedfilesharing'),
-                               \OC::$server->getCloudIdManager()
-                       );
-                       $this->notifications = new Notifications(
-                               $addressHandler,
-                               \OC::$server->getHTTPClientService(),
-                               \OC::$server->query(\OCP\OCS\IDiscoveryService::class),
-                               \OC::$server->getJobList(),
-                               \OC::$server->getCloudFederationProviderManager(),
-                               \OC::$server->getCloudFederationFactory()
-                       );
-               }
+
+       public function __construct(Notifications $notifications,
+                                                               ITimeFactory $timeFactory) {
+               parent::__construct($timeFactory);
+               $this->notifications = $notifications;
        }
 
        /**
@@ -126,7 +109,7 @@ class RetryJob extends Job {
                                'data' => $argument['data'],
                                'action' => $argument['action'],
                                'try' => (int)$argument['try'] + 1,
-                               'lastRun' => time()
+                               'lastRun' => $this->time->getTime()
                        ]
                );
        }
@@ -139,6 +122,6 @@ class RetryJob extends Job {
         */
        protected function shouldRun(array $argument) {
                $lastRun = (int)$argument['lastRun'];
-               return ((time() - $lastRun) > $this->interval);
+               return (($this->time->getTime() - $lastRun) > $this->interval);
        }
 }
index 71ea5417dd0dc6dc7ec3c1dd1de7701e56e4c43c..9390b047a91132d51376cad37b49294a0c5e9e06 100644 (file)
@@ -71,9 +71,6 @@ class GetSharedSecret extends Job {
        /** @var ILogger */
        private $logger;
 
-       /** @var ITimeFactory */
-       private $timeFactory;
-
        /** @var bool */
        protected $retainJob = false;
 
@@ -102,13 +99,13 @@ class GetSharedSecret extends Job {
                IDiscoveryService $ocsDiscoveryService,
                ITimeFactory $timeFactory
        ) {
+               parent::__construct($timeFactory);
                $this->logger = $logger;
                $this->httpClient = $httpClientService->newClient();
                $this->jobList = $jobList;
                $this->urlGenerator = $urlGenerator;
                $this->ocsDiscoveryService = $ocsDiscoveryService;
                $this->trustedServers = $trustedServers;
-               $this->timeFactory = $timeFactory;
        }
 
        /**
@@ -143,8 +140,8 @@ class GetSharedSecret extends Job {
 
        protected function run($argument) {
                $target = $argument['url'];
-               $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
-               $currentTime = $this->timeFactory->getTime();
+               $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
+               $currentTime = $this->time->getTime();
                $source = $this->urlGenerator->getAbsoluteURL('/');
                $source = rtrim($source, '/');
                $token = $argument['token'];
@@ -239,7 +236,7 @@ class GetSharedSecret extends Job {
         */
        protected function reAddJob(array $argument) {
                $url = $argument['url'];
-               $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
+               $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
                $token = $argument['token'];
                $this->jobList->add(
                        GetSharedSecret::class,
index 1c9b2539b3d221c70e1de45bb89bb8da3445ca80..c9bee9fa6be9992e0e59d7825fd26738f7ef94b0 100644 (file)
@@ -69,9 +69,6 @@ class RequestSharedSecret extends Job {
        /** @var ILogger */
        private $logger;
 
-       /** @var ITimeFactory */
-       private $timeFactory;
-
        /** @var bool */
        protected $retainJob = false;
 
@@ -100,13 +97,13 @@ class RequestSharedSecret extends Job {
                ILogger $logger,
                ITimeFactory $timeFactory
        ) {
+               parent::__construct($timeFactory);
                $this->httpClient = $httpClientService->newClient();
                $this->jobList = $jobList;
                $this->urlGenerator = $urlGenerator;
                $this->logger = $logger;
                $this->ocsDiscoveryService = $ocsDiscoveryService;
                $this->trustedServers = $trustedServers;
-               $this->timeFactory = $timeFactory;
        }
 
 
@@ -142,8 +139,8 @@ class RequestSharedSecret extends Job {
 
        protected function run($argument) {
                $target = $argument['url'];
-               $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
-               $currentTime = $this->timeFactory->getTime();
+               $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
+               $currentTime = $this->time->getTime();
                $source = $this->urlGenerator->getAbsoluteURL('/');
                $source = rtrim($source, '/');
                $token = $argument['token'];
@@ -211,7 +208,7 @@ class RequestSharedSecret extends Job {
         */
        protected function reAddJob(array $argument) {
                $url = $argument['url'];
-               $created = isset($argument['created']) ? (int)$argument['created'] : $this->timeFactory->getTime();
+               $created = isset($argument['created']) ? (int)$argument['created'] : $this->time->getTime();
                $token = $argument['token'];
 
                $this->jobList->add(
index d1b6d835fa4b790852d5312b475b73666cdfaec4..cb671f33466839f4cbd769ee1ccc10aa6816819b 100644 (file)
@@ -32,6 +32,7 @@ namespace OCA\Settings\BackgroundJobs;
 use OC\Accounts\AccountManager;
 use OCP\Accounts\IAccountManager;
 use OCP\AppFramework\Http;
+use OCP\AppFramework\Utility\ITimeFactory;
 use OCP\BackgroundJob\IJobList;
 use OCP\BackgroundJob\Job;
 use OCP\Http\Client\IClientService;
@@ -68,21 +69,14 @@ class VerifyUserData extends Job {
        /** @var IConfig */
        private $config;
 
-       /**
-        * VerifyUserData constructor.
-        *
-        * @param AccountManager $accountManager
-        * @param IUserManager $userManager
-        * @param IClientService $clientService
-        * @param ILogger $logger
-        * @param IConfig $config
-        */
        public function __construct(AccountManager $accountManager,
                                                                IUserManager $userManager,
                                                                IClientService $clientService,
                                                                ILogger $logger,
+                                                               ITimeFactory $timeFactory,
                                                                IConfig $config
        ) {
+               parent::__construct($timeFactory);
                $this->accountManager = $accountManager;
                $this->userManager = $userManager;
                $this->httpClientService = $clientService;