Add missing parent::__construct() calls to Jobs

Signed-off-by: Joas Schilling <coding@schilljs.com>
This commit is contained in:
Joas Schilling 2020-12-14 16:35:12 +01:00
parent 39bee7948d
commit 96253c7c1b
No known key found for this signature in database
GPG Key ID: 7076EA9751AACDDA
4 changed files with 19 additions and 48 deletions

View 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);
}
}

View 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,

View 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(

View 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;