harden code and ingester

This commit is contained in:
team 1
2026-02-12 14:31:29 +01:00
parent 5a52e07edc
commit 994f582f35
8 changed files with 77 additions and 496 deletions

View File

@@ -5,6 +5,7 @@ namespace App\Controller\Admin;
use App\Entity\Document;
use App\Entity\DocumentVersion;
use App\Entity\IngestJob;
use App\Service\DocumentService;
use App\Service\IngestOrchestrator;
use Doctrine\ORM\EntityManagerInterface;
@@ -183,16 +184,16 @@ class DocumentController extends AbstractController
#[Route(
'/version/{versionId}/ingest',
name: 'admin_document_version_ingest',
methods: ['POST'],
requirements: ['versionId' => '[0-9a-fA-F\-]{36}']
requirements: ['versionId' => '[0-9a-fA-F\-]{36}'],
methods: ['POST']
)]
public function ingestVersion(
string $versionId,
Request $request,
EntityManagerInterface $em,
IngestOrchestrator $orchestrator
): RedirectResponse {
): ?RedirectResponse {
$dryRun = false;
if (!$this->isCsrfTokenValid('ingest_version', $request->request->get('_token'))) {
throw $this->createAccessDeniedException();
}
@@ -203,10 +204,20 @@ class DocumentController extends AbstractController
throw $this->createNotFoundException();
}
$existing = $em->getRepository(IngestJob::class)
->findOneBy(
['documentVersionId' => $version->getId()],
['startedAt' => 'DESC']
);
if ($existing && $existing->getStartedAt() > new \DateTimeImmutable('-3 seconds')) {
return null;
}
$orchestrator->runForVersion(
$version,
$this->getUser(),
true // erstmal DryRun
$dryRun
);
return $this->redirectToRoute('admin_document_show', [