feat(scan): whiten receipt backgrounds and embed OCR in PDFs
This commit is contained in:
@@ -152,6 +152,7 @@ export default async function instanceAgentRoutes(server: FastifyInstance) {
|
||||
active: instanceAgents.active,
|
||||
preferredScannerName: instanceAgents.preferredScannerName,
|
||||
scanDefaults: instanceAgents.scanDefaults,
|
||||
capabilities: instanceAgents.capabilities,
|
||||
})
|
||||
.from(instanceAgents)
|
||||
.where(eq(instanceAgents.id, body.agentId))
|
||||
@@ -161,6 +162,14 @@ export default async function instanceAgentRoutes(server: FastifyInstance) {
|
||||
return reply.code(404).send({ error: "Active agent not found" })
|
||||
}
|
||||
|
||||
const settings = { ...((agent.scanDefaults || {}) as Record<string, any>), ...(body.settings || {}) }
|
||||
const enabled = (value: unknown) => value === true || (typeof value === "string" && ["1", "true", "yes", "ja", "on"].includes(value.toLowerCase().trim()))
|
||||
const capabilities = agent.capabilities as Record<string, any>
|
||||
if (((settings.format || "pdf") === "pdf" && enabled(settings.ocr) && !capabilities?.ocr) ||
|
||||
(enabled(settings.backgroundCleanup) && !capabilities?.backgroundCleanup)) {
|
||||
return reply.code(409).send({ error: "Bitte den Scanner-Agenten mit Tesseract und OpenCV aktualisieren. Die angeforderte Scan-Verarbeitung ist dort noch nicht verfügbar." })
|
||||
}
|
||||
|
||||
const [job] = await server.db
|
||||
.insert(instanceAgentScanJobs)
|
||||
.values({
|
||||
@@ -169,10 +178,7 @@ export default async function instanceAgentRoutes(server: FastifyInstance) {
|
||||
requestedBy: req.user?.user_id,
|
||||
scannerName: body.scannerName || agent.preferredScannerName,
|
||||
requestedFilename: body.requestedFilename,
|
||||
settings: {
|
||||
...((agent.scanDefaults || {}) as Record<string, any>),
|
||||
...(body.settings || {}),
|
||||
},
|
||||
settings,
|
||||
target: body.target || {},
|
||||
})
|
||||
.returning()
|
||||
|
||||
Reference in New Issue
Block a user