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