Files
deck/lib/Cron/SessionsCleanup.php
Ferdinand Thiessen beb563e74e refactor: Migrate away from deprecated ILogger interface to PSR-3
Mostly replace `ILogger` with `LoggerInterface` and some minor cleanup (constructor property promotion).
Some places used the deprecated `logException` this is easy to migrate by simply use the appropriate loglevel on the logger
and place the exception under the `exception` key in the context.
Also the manual checking of the configured log level is not needed, as this is already done by the logger.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2024-08-19 14:09:13 +02:00

40 lines
906 B
PHP

<?php
declare(strict_types=1);
/**
* SPDX-FileCopyrightText: 2022 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
namespace OCA\Deck\Cron;
use OCA\Deck\Service\SessionService;
use OCP\AppFramework\Utility\ITimeFactory;
use OCP\BackgroundJob\TimedJob;
use Psr\Log\LoggerInterface;
class SessionsCleanup extends TimedJob {
private $documentService;
private $imageService;
public function __construct(
ITimeFactory $time,
private SessionService $sessionService,
private LoggerInterface $logger,
) {
parent::__construct($time);
$this->setInterval(SessionService::SESSION_VALID_TIME);
}
protected function run($argument) {
$this->logger->debug('Run cleanup job for deck sessions');
$removedSessions = $this->sessionService->removeInactiveSessions();
$this->logger->debug('Removed ' . $removedSessions . ' inactive sessions');
}
}