use OCA\FederatedFileSharing\AddressHandler;
use OCA\FederatedFileSharing\Notifications;
+use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\IJobList;
use OCP\BackgroundJob\Job;
use OCP\ILogger;
/** @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;
}
/**
'data' => $argument['data'],
'action' => $argument['action'],
'try' => (int)$argument['try'] + 1,
- 'lastRun' => time()
+ 'lastRun' => $this->time->getTime()
]
);
}
*/
protected function shouldRun(array $argument) {
$lastRun = (int)$argument['lastRun'];
- return ((time() - $lastRun) > $this->interval);
+ return (($this->time->getTime() - $lastRun) > $this->interval);
}
}
/** @var ILogger */
private $logger;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var bool */
protected $retainJob = false;
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;
}
/**
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'];
*/
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,
/** @var ILogger */
private $logger;
- /** @var ITimeFactory */
- private $timeFactory;
-
/** @var bool */
protected $retainJob = false;
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;
}
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'];
*/
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(
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;
/** @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;