2016-01-22 08:58:49 -05:00
|
|
|
<?php
|
2024-05-28 10:42:42 -04:00
|
|
|
|
2016-01-22 08:58:49 -05:00
|
|
|
/**
|
2024-05-28 10:42:42 -04: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;
|
|
|
|
|
|
2022-06-24 09:24:16 -04:00
|
|
|
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 {
|
2024-10-18 06:04:22 -04:00
|
|
|
public function __construct(
|
|
|
|
|
protected SyncFederationAddressBooks $syncService,
|
|
|
|
|
protected LoggerInterface $logger,
|
|
|
|
|
ITimeFactory $timeFactory,
|
|
|
|
|
) {
|
2022-06-24 09:24:16 -04:00
|
|
|
parent::__construct($timeFactory);
|
2016-01-22 08:58:49 -05:00
|
|
|
// Run once a day
|
|
|
|
|
$this->setInterval(24 * 60 * 60);
|
2024-10-07 11:36:55 -04:00
|
|
|
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
|
2016-01-22 08:58:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected function run($argument) {
|
2024-09-20 11:38:36 -04:00
|
|
|
$this->syncService->syncThemAll(function ($url, $ex): void {
|
2016-01-22 08:58:49 -05:00
|
|
|
if ($ex instanceof \Exception) {
|
2022-07-04 09:43:04 -04:00
|
|
|
$this->logger->error("Error while syncing $url.", [
|
2022-06-24 09:24:16 -04:00
|
|
|
'exception' => $ex,
|
2018-01-17 09:21:56 -05:00
|
|
|
]);
|
2016-01-22 08:58:49 -05:00
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|