Exclude archived jobs from auto mail matching

This commit is contained in:
Ivo Oskamp 2026-03-12 14:44:44 +01:00
parent ec3a338170
commit 2ebe7d8aed
2 changed files with 15 additions and 0 deletions

View File

@ -35,6 +35,11 @@ def find_matching_job(msg: MailMessage) -> Optional[Job]:
q = Job.query
# Never auto-match archived jobs.
# Archived jobs should remain historical and must not receive new mail links/runs.
if hasattr(Job, "archived"):
q = q.filter(Job.archived.is_(False))
if norm_from is None:
q = q.filter(Job.from_address.is_(None))
else:
@ -86,6 +91,8 @@ def find_matching_job(msg: MailMessage) -> Optional[Job]:
return None
q2 = Job.query
if hasattr(Job, "archived"):
q2 = q2.filter(Job.archived.is_(False))
if norm_from is None:
q2 = q2.filter(Job.from_address.is_(None))
else:

View File

@ -2,6 +2,14 @@
This file documents all changes made to this project via Claude Code.
## [2026-03-12]
### Fixed
- Prevented automatic mail-to-job matching from selecting archived jobs:
- Updated `app/job_matching.py` so `find_matching_job()` excludes `jobs.archived = true`.
- Applied the same archived filter in the VSPC normalized fallback match path.
- This prevents new imports/re-parse auto-approval from attaching messages/runs to archived jobs.
## [2026-03-02]
### Fixed