refactor: replace direct Paperless upload with client-side document download functionality
Build and Push Multi-Platform Images / build-and-push (push) Successful in 36s

This commit is contained in:
2026-05-06 09:30:53 +02:00
parent 4f1f030423
commit e08a5697f0
5 changed files with 34 additions and 137 deletions
+4 -18
View File
@@ -14,7 +14,6 @@ import {
InboxDocument,
type InboxSource,
} from '../database/entities/inbox-document.entity';
import { PaperlessService } from '../paperless/paperless.service';
import { MailService } from '../postprocessing/mail.service';
import { applyEditsToTemp, cleanupTemp } from '../inbox-postprocessor/edit-applier';
@@ -44,7 +43,6 @@ export class InboxService {
private readonly pageCache: PageCacheService,
@InjectRepository(InboxDocument)
private readonly documentRepo: Repository<InboxDocument>,
private readonly paperlessService: PaperlessService,
private readonly mailService: MailService,
) {}
@@ -255,28 +253,16 @@ export class InboxService {
return this.barcodeScanner.scanRegion(doc, pdfPath, page, x, y, w, h);
}
async saveToPaperless(
async getEditedPdfBuffer(
id: string,
preferredUsername: string | null,
opts: {
title: string;
date?: string;
documentTypeId?: number;
correspondentId?: number;
tagIds?: number[];
},
): Promise<void> {
): Promise<{ buffer: Buffer; filename: string }> {
const { doc, pdfPath } = await this.resolveDocument(id, preferredUsername);
let tmpPath: string | null = null;
try {
tmpPath = await applyEditsToTemp(doc, pdfPath);
await this.paperlessService.uploadDocument(tmpPath, {
title: opts.title,
created: opts.date,
documentType: opts.documentTypeId,
correspondent: opts.correspondentId,
tags: opts.tagIds,
});
const buffer = await fs.readFile(tmpPath);
return { buffer, filename: doc.OriginalName };
} finally {
await cleanupTemp(tmpPath);
}