fix: Kennzahlen mit Timeout laden, ungültige Seitenbereiche als 400 melden

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
bjoernpoettkerandClaude Opus 5.5 committed 2026-11-02 14:22:44 +01:00
1 parent 32b5228f68
commit 79dadb9c93
3 files changed
+70 -6

No files matched your search

@@ -4,6 +4,7 @@ import {
HttpException,
HttpStatus,
ConflictException,
BadRequestException,
} from '@nestjs/common';
import { ConfigService } from '@nestjs/config';
import { InjectRepository } from '@nestjs/typeorm';
@@ -370,8 +371,19 @@ export class EmailImportService {
ignoreEncryption: true,
});
const total = pdfDoc.getPageCount();
const startIdx = Math.max(1, pages.start) - 1;
const endIdx = Math.min(pages.end === 999 ? total : pages.end, total) - 1;
const ende = pages.end === 999 ? total : Math.min(pages.end, total);
if (
!Number.isInteger(pages.start) ||
!Number.isInteger(ende) ||
pages.start < 1 ||
pages.start > ende
) {
throw new BadRequestException(
`Ungültiger Seitenbereich ${pages.start}–${pages.end} (Dokument hat ${total} Seiten)`,
);
}
const startIdx = pages.start - 1;
const endIdx = ende - 1;
const sliced = await PDFDocument.create();
const indices = Array.from(
{ length: endIdx - startIdx + 1 },