f7cloud_client/apps/gigachat_integration/lib/Middleware/StartJobMiddleware.php
root 8b6a0139db f7cloud_client
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-17 22:59:26 +00:00

34 lines
1.0 KiB
PHP

<?php
declare(strict_types=1);
namespace OCA\GigaChat\Middleware;
use OCA\Assistant\Controller\ChattyLLMController;
use OC\TaskProcessing\SynchronousBackgroundJob;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Middleware;
use OCP\BackgroundJob\IJobList;
class StartJobMiddleware extends Middleware {
public function __construct(
private IJobList $jobList,
) {
}
public function afterController(Controller $controller, string $methodName, Response $response) {
if (
($controller instanceof ChattyLLMController)
&& ($methodName == 'generateForSession')
) {
$job_iter = $this->jobList->getJobsIterator(SynchronousBackgroundJob::class, 1, 0);
foreach ($job_iter as $job) {
$job->start($this->jobList);
}
}
return $response;
}
}