forked from NuQloud/nc-talk-ai
35 lines
967 B
PHP
35 lines
967 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace OCA\EducAI\Jobs;
|
|
|
|
use OCA\EducAI\Db\PendingToolConfirmationMapper;
|
|
use OCP\AppFramework\Utility\ITimeFactory;
|
|
use OCP\BackgroundJob\TimedJob;
|
|
use Psr\Log\LoggerInterface;
|
|
|
|
class CleanupToolConfirmationsJob extends TimedJob {
|
|
public function __construct(
|
|
ITimeFactory $time,
|
|
private PendingToolConfirmationMapper $confirmationMapper,
|
|
private LoggerInterface $logger,
|
|
) {
|
|
parent::__construct($time);
|
|
$this->setInterval(3600);
|
|
$this->setTimeSensitivity(self::TIME_INSENSITIVE);
|
|
}
|
|
|
|
/** @param array<string,mixed> $arguments */
|
|
protected function run($arguments): void {
|
|
try {
|
|
$deleted = $this->confirmationMapper->cleanupExpired(time());
|
|
if ($deleted > 0) {
|
|
$this->logger->debug('EducAI: Cleaned up expired tool confirmations', ['deleted' => $deleted]);
|
|
}
|
|
} catch (\Throwable $e) {
|
|
$this->logger->error('EducAI: Failed to clean up expired tool confirmations', ['exception' => $e]);
|
|
}
|
|
}
|
|
}
|