Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 8 additions & 26 deletions apps/federatedfilesharing/lib/BackgroundJob/RetryJob.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@

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;
Expand All @@ -55,29 +55,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;
}

/**
Expand Down Expand Up @@ -126,7 +108,7 @@ protected function reAddJob(IJobList $jobList, array $argument) {
'data' => $argument['data'],
'action' => $argument['action'],
'try' => (int)$argument['try'] + 1,
'lastRun' => time()
'lastRun' => $this->time->getTime()
]
);
}
Expand All @@ -139,6 +121,6 @@ protected function reAddJob(IJobList $jobList, array $argument) {
*/
protected function shouldRun(array $argument) {
$lastRun = (int)$argument['lastRun'];
return ((time() - $lastRun) > $this->interval);
return (($this->time->getTime() - $lastRun) > $this->interval);
}
}
11 changes: 4 additions & 7 deletions apps/federation/lib/BackgroundJob/GetSharedSecret.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,6 @@ class GetSharedSecret extends Job {
/** @var ILogger */
private $logger;

/** @var ITimeFactory */
private $timeFactory;

/** @var bool */
protected $retainJob = false;

Expand Down Expand Up @@ -102,13 +99,13 @@ public function __construct(
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;
}

/**
Expand Down Expand Up @@ -143,8 +140,8 @@ protected function parentExecute($jobList, $logger = null) {

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'];
Expand Down Expand Up @@ -239,7 +236,7 @@ protected function run($argument) {
*/
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,
Expand Down
11 changes: 4 additions & 7 deletions apps/federation/lib/BackgroundJob/RequestSharedSecret.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,6 @@ class RequestSharedSecret extends Job {
/** @var ILogger */
private $logger;

/** @var ITimeFactory */
private $timeFactory;

/** @var bool */
protected $retainJob = false;

Expand Down Expand Up @@ -100,13 +97,13 @@ public function __construct(
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;
}


Expand Down Expand Up @@ -142,8 +139,8 @@ protected function parentExecute($jobList, $logger) {

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'];
Expand Down Expand Up @@ -211,7 +208,7 @@ protected function run($argument) {
*/
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(
Expand Down
12 changes: 3 additions & 9 deletions apps/settings/lib/BackgroundJobs/VerifyUserData.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
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;
Expand Down Expand Up @@ -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;
Expand Down