fix: comprehensive portal audit - bugfixes, performance, security, logo

Critical bugs:
- Fix bulk-download: UUID idempotency key, input validation, error handling, parallel asset validation
- Fix leuchtkasten 404 link -> album page with search
- Fix revalidatePath [id] -> [albumId]
- Fix PDF crash on null invoiceNumber

Logo:
- Fix dimensions (1000x1000), dark mode support (logo-white.png), max-height constraint

UI bugs:
- Fix unsafe Date method calls (6 files)
- Fix album UUID shown instead of name in catalog
- Fix global search downloads (albumId from asset)
- Add null guard for lightbox asset map

Performance:
- Parallelize admin dashboard queries (Promise.all)
- Lazy-load recharts via next/dynamic
- Add thumbnail caching headers (24h + ETag)
- Reduce duplicate Immich API calls in usage service
- Add DB index on usages(createdAt)
- Add optimizePackageImports for lucide-react, recharts

Security:
- Input validation on bulk-download (max 100 items, UUID format, purpose length)
- Verify security headers present in next.config.ts
This commit is contained in:
Leon Tonhäuser committed 2026-08-11 11:50:12 +02:00
1 parent 0576d946c5
commit d9d69ed861
21 files changed
+229 -153

No files matched your search

+3 -3
View File
@@ -96,13 +96,13 @@ export function PhotoContactSheet({
<figcaption className="contact-strip">
<span className="contact-strip-name">{asset.originalFileName}</span>
{showAlbumName && (asset as any).albums && (asset as any).albums.length > 0 && (
<span className="contact-strip-album">{(asset as any).albums[0].id}</span>
<span className="contact-strip-album">{(asset as any).albums[0].albumName}</span>
)}
<span>{formatDate(asset.localDateTime ?? asset.fileCreatedAt)}</span>
</figcaption>
{albumId && downloadOptions ? (
{(albumId ?? asset.albums?.[0]?.id) && downloadOptions ? (
<UsageDialog
albumId={albumId}
albumId={albumId ?? (asset.albums?.[0]?.id as string)}
assetId={asset.id}
filename={asset.originalFileName}
newUsagePriceCents={downloadOptions.priceCents}
+1 -1
View File
@@ -32,7 +32,7 @@ export function EditorialDetailContent({
{editorial.archivedAt && (
<div className="bg-destructive/15 text-destructive p-4 rounded-md border border-destructive/30" role="status">
Diese Redaktion wurde am {editorial.archivedAt.toLocaleDateString('de-DE')} archiviert.
Diese Redaktion wurde am {new Date(editorial.archivedAt).toLocaleDateString('de-DE')} archiviert.
</div>
)}
+7 -17
View File
@@ -89,16 +89,16 @@ export function createUsageService({
const existing = await repository.findIntent(input.editorialId, input.idempotencyKey);
if (existing) return resolveIntent(existing, fingerprint, "new_usage");
const album = await loadRequestedAlbum(immich, input.assetId, input.albumId);
const asset = await loadImageAsset(immich, input.assetId);
const asset = await getValidatedAsset(immich, input.assetId);
const album = await loadRequestedAlbum(immich, asset, input.albumId);
const persisted = await repository.createBillableIntent({
...input,
albumName: normalizeUpstreamSnapshot(album.albumName),
filename: normalizeUpstreamSnapshot(asset.originalFileName),
requestFingerprint: fingerprint,
}, async () => {
const currentAlbum = await loadRequestedAlbum(immich, input.assetId, input.albumId);
const currentAsset = await loadImageAsset(immich, input.assetId);
const currentAsset = await getValidatedAsset(immich, input.assetId);
const currentAlbum = await loadRequestedAlbum(immich, currentAsset, input.albumId);
return {
albumName: normalizeUpstreamSnapshot(currentAlbum.albumName),
filename: normalizeUpstreamSnapshot(currentAsset.originalFileName),
@@ -330,31 +330,21 @@ function normalizeNewUsageInput(input: CreateNewUsageInput): CreateNewUsageInput
async function loadRequestedAlbum(
immich: UsageImmich,
assetId: string,
asset: { albums: Array<{ id: string }> },
albumId: string,
): Promise<{ id: string; albumName: string }> {
let asset;
try {
asset = await immich.getAsset(assetId);
} catch {
throw new UsageAccountingError("IMMICH_UNAVAILABLE");
}
if (!asset.albums.some((a) => a.id === albumId)) {
throw new UsageAccountingError("ASSET_NOT_IN_ALBUM");
}
let album;
try {
album = await immich.getAlbum(albumId);
return await immich.getAlbum(albumId);
} catch {
throw new UsageAccountingError("IMMICH_UNAVAILABLE");
}
return album;
}
async function loadImageAsset(immich: UsageImmich, assetId: string) {
async function getValidatedAsset(immich: UsageImmich, assetId: string) {
let asset: Awaited<ReturnType<UsageImmich["getAsset"]>>;
try {
asset = await immich.getAsset(assetId);