feat: implement region-based QR code scanning for inbox documents
Build and Push Multi-Platform Images / build-and-push (push) Successful in 33s

This commit is contained in:
2026-05-04 21:39:32 +02:00
parent 60ac522435
commit 9a1095ad6e
7 changed files with 226 additions and 3 deletions
@@ -143,6 +143,17 @@ export class InboxController {
return new StreamableFile(createReadStream(filePath));
}
@Post(':id/pages/:page/scan-region')
async scanRegion(
@Param('id') id: string,
@Param('page', ParseIntPipe) page: number,
@Body() body: { x: number; y: number; w: number; h: number },
@Request() req: any,
): Promise<{ found: string[] }> {
const preferredUsername: string | null = req.user?.preferredUsername ?? null;
return this.inboxService.scanRegion(id, page, body.x, body.y, body.w, body.h, preferredUsername);
}
@Post(':id/source')
@HttpCode(204)
async updateSource(
+15 -2
View File
@@ -44,8 +44,8 @@ export class InboxService {
async listFiles(preferredUsername: string | null): Promise<InboxFile[]> {
const where = preferredUsername
? [{ Source: 'all' as InboxSource }, { Source: 'user' as InboxSource, OwnerUsername: preferredUsername }]
: [{ Source: 'all' as InboxSource }];
? [{ Source: 'all' as InboxSource, IsScanned: true }, { Source: 'user' as InboxSource, OwnerUsername: preferredUsername, IsScanned: true }]
: [{ Source: 'all' as InboxSource, IsScanned: true }];
const docs = await this.documentRepo.find({
where,
@@ -212,4 +212,17 @@ export class InboxService {
await this.documentRepo.save(doc);
}
async scanRegion(
id: string,
page: number,
x: number,
y: number,
w: number,
h: number,
preferredUsername: string | null,
): Promise<{ found: string[] }> {
const { doc, pdfPath } = await this.resolveDocument(id, preferredUsername);
return this.barcodeScanner.scanRegion(doc, pdfPath, page, x, y, w, h);
}
}