fix(PROJ-44): IMAP+POP3 Live-Import triggert OCR-Worker

Bisher haben nur der SMTP-Pfad und der Boot-Backfill ocrWorker.Submit
gerufen. IMAP- und POP3-Importer riefen nur idx.IndexSync auf —
neue Mails blieben dadurch dauerhaft in ocr_status='pending' (auf 132
44 Tage 54 Mails so haengen geblieben).

Fix: Importer-Strukturen bekommen einen optionalen ocrSubmit-Callback,
in main.go via SetOCRSubmit gehookt. Kein Import von internal/ocr in
die Importer-Packages -> kein Risiko von Cycles. Submit ist
non-blocking; bei Mails ohne Attachments markiert der Worker selbst
'skipped'.
This commit is contained in:
sysops
2026-05-10 22:23:24 +02:00
parent a44fd1ae44
commit 032892bc2b
3 changed files with 43 additions and 0 deletions
+13
View File
@@ -413,6 +413,13 @@ func main() {
}
defer imapSt.Close()
imapImp := imapstore.NewImporter(imapSt, mailStore, idx, logger)
// PROJ-44: trigger OCR for IMAP-imported mails — without this every
// IMAP delivery would remain in ocr_status='pending' forever.
if ocrWorker != nil {
imapImp.SetOCRSubmit(func(mailID string, tenantID *int64) {
ocrWorker.Submit(mailID, tenantID)
})
}
imapSched := imapstore.NewScheduler(imapSt, imapImp, logger)
imapSched.Start()
defer imapSched.Stop()
@@ -426,6 +433,12 @@ func main() {
}
defer pop3St.Close()
pop3Imp := pop3store.NewImporter(pop3St, mailStore, idx, logger)
// PROJ-44: same OCR hook as the IMAP importer above.
if ocrWorker != nil {
pop3Imp.SetOCRSubmit(func(mailID string, tenantID *int64) {
ocrWorker.Submit(mailID, tenantID)
})
}
srv.SetPop3(pop3St, pop3Imp)
// Backfill in background: migrate existing files into DB metadata + re-index