The cps datensysteme rule (from cps-datensysteme.de + subject "Rechnung"
+ has_attachment true + date after) was failing on real invoices from
CPS ORMS. Their PDFs arrive without a Content-Disposition header — the
filename lives only on the Content-Type parameter — so _has_attachment
returned False and the rule never matched.
Extended the check to also count a part as an attachment when it has a
filename() and its content-type is neither text/* nor multipart/*.
That catches PDFs, Office and image attachments regardless of whether
the sender set Content-Disposition, without treating body parts as
attachments. Verified against four synthetic cases including the exact
CPS ORMS shape.
Same helper is now applied to non-multipart mails too, in case an entire
mail is a single attached file (rare but possible).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The per-rule batch was sliced from all_uids in server order (oldest
UID first), so with a big backlog the scheduler chewed through years
of unmatched newsletters before reaching the current invoices the
user was actually waiting on. Sort new_uids descending by int (with a
plain reverse() fallback for non-numeric UIDs) so each poll picks the
newest 500 first. Old backlog still gets worked off in the background.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- fix: fetch_mail crashed on MIME pseudo-encodings like 'unknown-8bit',
'x-unknown', '8bit'. New _safe_decode helper maps those (and any
LookupError from unknown codecs) to latin-1, which never fails on
8-bit input. Used in _extract_body and _decode_header_value.
- Consequence of the crash: scheduler marked the affected UIDs as
processed to avoid retry loops, so those mails never got sorted
even after the underlying issue was fixable.
- feat: POST /api/filters/retry-failed drops the ProcessedMail markers
for UIDs that appear in "Fehler beim Abrufen" error logs, so the
next poll re-evaluates them. Reachable via a button in the log UI
("Fehlgeschlagene neu einlesen"), optionally scoped per account.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- fix: Starlette 1.0 changed TemplateResponse signature — request is now
the first positional argument, not nested inside the context dict.
All HTML routes returned 500 (unhashable dict in jinja2 template cache)
after the image rebuild picked up the new starlette version.
- fix: processed_mails (1.7M rows in production: 1 account × 12 rules ×
141k inbox mails) made backup export hit 558 MB / 90s. Moved to opt-in
checkbox in the UI alongside the logs option, default off.
- yield_per for streaming the processed_mails query when included.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
- fix: imap folder names with spaces (RFC3501 quoting in move/create/select)
- fix: move only deletes source after COPY + Message-ID verification in target
- fix: backup endpoint hung on sqlite write locks — enable WAL + busy_timeout
- perf: indexes on filter_logs(created_at, level, account_id+created_at) for
fast log queries on millions of rows
- feat: optional "logs mit sichern" checkbox in backup export, restore on import
- UI: backup download uses fetch+blob with error display instead of location.href
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>