Files
tern-server/.env.example
T
Mateusz PstruchaandClaude Opus 5.5 3f1d9227c6
CI / test (push) Successful in 46s
Add trash retention, stop-after-match and run-now
Mail in Trash is purged after TRASH_RETENTION_DAYS (default 30, 0
disables), hourly. Stored files are content-addressed and shared, so a
file is only removed once nothing references it — and not if written or
reused in the last hour, since ingest writes a file before inserting the
row that points at it. Reusing an existing blob now refreshes its mtime
so that grace period protects it too. Trash rows report when they purge.

"Stop processing further rules" moves from an action to a per-rule
option (stop_after_match): it's a property of the rule, not something
done to a message. Migration 0007 converts existing stop actions, and a
stop submitted as an action is now rejected.

Rules can be run now against existing mail outside Trash, disabled ones
included so a rule can be tried before it's switched on. It pages by
key, one transaction per page, and only re-reads stored raw messages
when the rule tests a header.

All JSON bodies now go through an AppJson extractor so malformed or
mistyped bodies return the API's {"error": …} shape. Axum's default was
a plain-text 422 the webapp could only show as "request failed: 422" —
losing the useful part, e.g. "unknown variant `stop`".

Verified live: the stop flag blocks a lower rule on arriving mail; run
now on a disabled header rule archived 2 of 4 messages; a purge removed
an expired message and its unique raw file while keeping an attachment
file still shared with a live copy, with no orphaned rows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-23 12:00:04 +02:00

20 lines
705 B
Bash

# Copy to .env for local development (docker-compose reads this automatically
# for the `db` service password; the app reads it via dotenvy at startup).
DATABASE_URL=postgres://tern:tern@localhost:5432/tern
BIND_ADDR=127.0.0.1:8080
# 32 random bytes, base64-encoded. Generate with: openssl rand -base64 32
# Encrypts stored IMAP/SMTP credentials at rest (see src/crypto.rs). Losing
# this key makes every stored account credential unrecoverable — back it up
# outside the database.
CREDENTIAL_KEY=
BLOB_STORAGE_DIR=./data/blobs
SESSION_TTL_HOURS=720
# Days mail stays in Trash before it's permanently deleted. 0 disables purging.
TRASH_RETENTION_DAYS=30
RUST_LOG=tern_server=debug,tower_http=debug