From 96253c7c1b02c9e3a5506198c179dd7a32d01fbe Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Mon, 14 Dec 2020 16:35:12 +0100 Subject: Add missing parent::__construct() calls to Jobs Signed-off-by: Joas Schilling --- .../lib/BackgroundJob/RetryJob.php | 33 ++++++---------------- 1 file changed, 8 insertions(+), 25 deletions(-) (limited to 'apps/federatedfilesharing/lib') diff --git a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php index 4949e5794b4..14d86d4b444 100644 --- a/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php +++ b/apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php @@ -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); } } -- cgit v1.2.3