fix: Date-Parsing-Fallback für nicht-standard MTA-Datumsformate

mailparser: weitere Layouts (Timezone +02:00 mit Doppelpunkt, ohne Sekunden)
storage: GetReceivedAts() für Batch-Lookup von received_at
search_handlers: received_at als Fallback wenn pm.Date.IsZero()

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
sysops
2026-05-11 23:36:18 +02:00
parent 1f7e02dc53
commit a1c4e59fff
3 changed files with 39 additions and 1 deletions
+25
View File
@@ -682,6 +682,31 @@ func (s *Store) Delete(id string) error {
return nil
}
// GetReceivedAts returns the received_at timestamp for each mail ID in the
// provided slice. Used as a date fallback when the email Date header cannot
// be parsed. Missing IDs are silently omitted from the result map.
func (s *Store) GetReceivedAts(ctx context.Context, ids []string) map[string]time.Time {
if s.db == nil || len(ids) == 0 {
return nil
}
// pgx supports $1 = []string via ANY
rows, err := s.db.Query(ctx,
`SELECT id, received_at FROM emails WHERE id = ANY($1)`, ids)
if err != nil {
return nil
}
defer rows.Close()
result := make(map[string]time.Time, len(ids))
for rows.Next() {
var id string
var t time.Time
if err := rows.Scan(&id, &t); err == nil {
result[id] = t
}
}
return result
}
// Purge deletes all mails whose retain_until has passed.
// Returns the number of successfully deleted mails.
// Mails that fail to delete (e.g. file missing) are skipped silently.