mirror of
https://github.com/nextcloud/server.git
synced 2025-03-16 17:24:10 +00:00
Use proper OCP\BackgroundJobs\Job
And typehunt the IJobList Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
parent
d4fd61b7c6
commit
6166e1a157
7 changed files with 19 additions and 21 deletions
apps
dav
federatedfilesharing/lib/BackgroundJob
federation/lib/BackgroundJob
lookup_server_connector/lib/BackgroundJobs
settings/lib/BackgroundJobs
|
@ -30,9 +30,10 @@ declare(strict_types=1);
|
|||
namespace OCA\DAV\BackgroundJob;
|
||||
|
||||
use DateInterval;
|
||||
use OC\BackgroundJob\Job;
|
||||
use OCA\DAV\CalDAV\WebcalCaching\RefreshWebcalService;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
use Sabre\VObject\DateTimeParser;
|
||||
|
@ -65,6 +66,7 @@ class RefreshWebcalJob extends Job {
|
|||
* @param ITimeFactory $timeFactory
|
||||
*/
|
||||
public function __construct(RefreshWebcalService $refreshWebcalService, IConfig $config, ILogger $logger, ITimeFactory $timeFactory) {
|
||||
parent::__construct($timeFactory);
|
||||
$this->refreshWebcalService = $refreshWebcalService;
|
||||
$this->config = $config;
|
||||
$this->logger = $logger;
|
||||
|
@ -76,7 +78,7 @@ class RefreshWebcalJob extends Job {
|
|||
*
|
||||
* @inheritdoc
|
||||
*/
|
||||
public function execute($jobList, ILogger $logger = null) {
|
||||
public function execute(IJobList $jobList, ILogger $logger = null) {
|
||||
$subscription = $this->refreshWebcalService->getSubscription($this->argument['principaluri'], $this->argument['uri']);
|
||||
if (!$subscription) {
|
||||
return;
|
||||
|
|
|
@ -74,6 +74,7 @@ class RefreshWebcalJobTest extends TestCase {
|
|||
*/
|
||||
public function testRun(int $lastRun, int $time, bool $process) {
|
||||
$backgroundJob = new RefreshWebcalJob($this->refreshWebcalService, $this->config, $this->logger, $this->timeFactory);
|
||||
$backgroundJob->setId(42);
|
||||
|
||||
$backgroundJob->setArgument([
|
||||
'principaluri' => 'principals/users/testuser',
|
||||
|
@ -99,8 +100,7 @@ class RefreshWebcalJobTest extends TestCase {
|
|||
->with('dav', 'calendarSubscriptionRefreshRate', 'P1W')
|
||||
->willReturn('P1W');
|
||||
|
||||
$this->timeFactory->expects($this->once())
|
||||
->method('getTime')
|
||||
$this->timeFactory->method('getTime')
|
||||
->willReturn($time);
|
||||
|
||||
if ($process) {
|
||||
|
|
|
@ -27,11 +27,10 @@
|
|||
|
||||
namespace OCA\FederatedFileSharing\BackgroundJob;
|
||||
|
||||
use OC\BackgroundJob\Job;
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCA\FederatedFileSharing\AddressHandler;
|
||||
use OCA\FederatedFileSharing\Notifications;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\ILogger;
|
||||
|
||||
/**
|
||||
|
@ -84,10 +83,10 @@ class RetryJob extends Job {
|
|||
/**
|
||||
* run the job, then remove it from the jobList
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger|null $logger
|
||||
*/
|
||||
public function execute($jobList, ILogger $logger = null) {
|
||||
public function execute(IJobList $jobList, ILogger $logger = null) {
|
||||
if ($this->shouldRun($this->argument)) {
|
||||
parent::execute($jobList, $logger);
|
||||
$jobList->remove($this, $this->argument);
|
||||
|
|
|
@ -32,12 +32,11 @@ namespace OCA\Federation\BackgroundJob;
|
|||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Ring\Exception\RingException;
|
||||
use OC\BackgroundJob\Job;
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCA\Federation\TrustedServers;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\Http\Client\IClient;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\Http\Client\IResponse;
|
||||
|
@ -115,7 +114,7 @@ class GetSharedSecret extends Job {
|
|||
/**
|
||||
* run the job, then remove it from the joblist
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger|null $logger
|
||||
*/
|
||||
public function execute(IJobList $jobList, ILogger $logger = null) {
|
||||
|
@ -135,7 +134,7 @@ class GetSharedSecret extends Job {
|
|||
/**
|
||||
* call execute() method of parent
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger $logger
|
||||
*/
|
||||
protected function parentExecute($jobList, $logger = null) {
|
||||
|
|
|
@ -31,12 +31,11 @@ namespace OCA\Federation\BackgroundJob;
|
|||
use GuzzleHttp\Exception\ClientException;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use GuzzleHttp\Ring\Exception\RingException;
|
||||
use OC\BackgroundJob\Job;
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCA\Federation\TrustedServers;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\AppFramework\Utility\ITimeFactory;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\Http\Client\IClient;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\ILogger;
|
||||
|
@ -114,7 +113,7 @@ class RequestSharedSecret extends Job {
|
|||
/**
|
||||
* run the job, then remove it from the joblist
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger|null $logger
|
||||
*/
|
||||
public function execute(IJobList $jobList, ILogger $logger = null) {
|
||||
|
@ -134,7 +133,7 @@ class RequestSharedSecret extends Job {
|
|||
/**
|
||||
* call execute() method of parent
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger $logger
|
||||
*/
|
||||
protected function parentExecute($jobList, $logger) {
|
||||
|
|
|
@ -95,7 +95,7 @@ class RetryJob extends Job {
|
|||
* @param IJobList $jobList
|
||||
* @param ILogger|null $logger
|
||||
*/
|
||||
public function execute($jobList, ILogger $logger = null): void {
|
||||
public function execute(IJobList $jobList, ILogger $logger = null): void {
|
||||
if (!isset($this->argument['userId'])) {
|
||||
// Old background job without user id, just drop it.
|
||||
$jobList->remove($this, $this->argument);
|
||||
|
|
|
@ -30,10 +30,9 @@
|
|||
namespace OCA\Settings\BackgroundJobs;
|
||||
|
||||
use OC\Accounts\AccountManager;
|
||||
use OC\BackgroundJob\Job;
|
||||
use OC\BackgroundJob\JobList;
|
||||
use OCP\AppFramework\Http;
|
||||
use OCP\BackgroundJob\IJobList;
|
||||
use OCP\BackgroundJob\Job;
|
||||
use OCP\Http\Client\IClientService;
|
||||
use OCP\IConfig;
|
||||
use OCP\ILogger;
|
||||
|
@ -96,10 +95,10 @@ class VerifyUserData extends Job {
|
|||
/**
|
||||
* run the job, then remove it from the jobList
|
||||
*
|
||||
* @param JobList $jobList
|
||||
* @param IJobList $jobList
|
||||
* @param ILogger|null $logger
|
||||
*/
|
||||
public function execute($jobList, ILogger $logger = null) {
|
||||
public function execute(IJobList $jobList, ILogger $logger = null) {
|
||||
if ($this->shouldRun($this->argument)) {
|
||||
parent::execute($jobList, $logger);
|
||||
$jobList->remove($this, $this->argument);
|
||||
|
|
Loading…
Reference in a new issue