nextcloud/apps/federation/lib/SyncJob.php

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

36 lines
893 B
PHP
Raw Normal View History

2016-01-22 08:58:49 -05:00
<?php
2016-01-22 08:58:49 -05:00
/**
* SPDX-FileCopyrightText: 2017-2024 Nextcloud GmbH and Nextcloud contributors
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
* SPDX-License-Identifier: AGPL-3.0-only
2016-01-22 08:58:49 -05:00
*/
namespace OCA\Federation;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use Psr\Log\LoggerInterface;
2016-01-22 08:58:49 -05:00
class SyncJob extends TimedJob {
public function __construct(
protected SyncFederationAddressBooks $syncService,
protected LoggerInterface $logger,
ITimeFactory $timeFactory,
) {
parent::__construct($timeFactory);
2016-01-22 08:58:49 -05:00
// Run once a day
$this->setInterval(24 * 60 * 60);
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
2016-01-22 08:58:49 -05:00
}
protected function run($argument) {
$this->syncService->syncThemAll(function ($url, $ex): void {
2016-01-22 08:58:49 -05:00
if ($ex instanceof \Exception) {
$this->logger->error("Error while syncing $url.", [
'exception' => $ex,
]);
2016-01-22 08:58:49 -05:00
}
});
}
}