From 64318c92e787b4e6bc8701da7da169de140b03a2 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 2 Apr 2026 10:00:12 +0300 Subject: [PATCH] fix(ocr): route default interfering with content language --- apps/server/src/routes/api/ocr.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/apps/server/src/routes/api/ocr.ts b/apps/server/src/routes/api/ocr.ts index ab4008090c..96188f4b65 100644 --- a/apps/server/src/routes/api/ocr.ts +++ b/apps/server/src/routes/api/ocr.ts @@ -27,8 +27,10 @@ import sql from "../../services/sql.js"; * properties: * language: * type: string - * description: OCR language code (e.g. 'eng', 'fra', 'deu') - * default: 'eng' + * description: > + * Tesseract language code to use (e.g. 'eng', 'fra', 'deu', 'eng+fra'). + * If omitted, the language is resolved automatically from the note's language label, + * the enabled content languages, or the UI locale. * forceReprocess: * type: boolean * description: Force reprocessing even if OCR already exists @@ -37,7 +39,7 @@ import sql from "../../services/sql.js"; * '200': * description: OCR processing completed successfully * '400': - * description: Bad request - OCR disabled or unsupported file type + * description: Bad request - unsupported file type * '404': * description: Note not found * '500': @@ -48,7 +50,7 @@ import sql from "../../services/sql.js"; */ async function processNoteOCR(req: Request<{ noteId: string }>) { const { noteId } = req.params; - const { language = 'eng', forceReprocess = false } = req.body || {}; + const { language, forceReprocess = false } = req.body || {}; const note = becca.getNote(noteId); if (!note) { @@ -85,8 +87,10 @@ async function processNoteOCR(req: Request<{ noteId: string }>) { * properties: * language: * type: string - * description: OCR language code (e.g. 'eng', 'fra', 'deu') - * default: 'eng' + * description: > + * Tesseract language code to use (e.g. 'eng', 'fra', 'deu', 'eng+fra'). + * If omitted, the language is resolved automatically from the owner note's language label, + * the enabled content languages, or the UI locale. * forceReprocess: * type: boolean * description: Force reprocessing even if OCR already exists @@ -95,7 +99,7 @@ async function processNoteOCR(req: Request<{ noteId: string }>) { * '200': * description: OCR processing completed successfully * '400': - * description: Bad request - OCR disabled or unsupported file type + * description: Bad request - unsupported file type * '404': * description: Attachment not found * '500': @@ -106,7 +110,7 @@ async function processNoteOCR(req: Request<{ noteId: string }>) { */ async function processAttachmentOCR(req: Request<{ attachmentId: string }>) { const { attachmentId } = req.params; - const { language = 'eng', forceReprocess = false } = req.body || {}; + const { language, forceReprocess = false } = req.body || {}; const attachment = becca.getAttachment(attachmentId); if (!attachment) {