Per review §1 — verified no callers before each deletion:
- _next_scrape_utc (context dict key never read by any template)
- ALERT_SCRAPE_INTERVAL_SECONDS settings import (only _next_scrape_utc read it)
- alert/paths.py (imported by nothing)
- alert/settings.py LANGUAGE (alert doesn't use translations.toml)
- alert/main.py: the vestigial `c = {}` connectivity dict, the comment
about re-enabling it, and the entire connectivity block in
_flat_payload — the web-side columns stay NULL on insert now
- alert/maps.py: DESTINATIONS, calculate_score, _get_next_weekday,
_calculate_transfers (only geocode is used in the scraper)
- alert/flat.py: connectivity + display_address properties,
_connectivity field, unused datetime import
- apply/utils.py str_to_preview (no callers) — file removed
- web/matching.py: max_morning_commute + commute check
- web/app.py: don't pass connectivity dict into flat_matches_filter,
don't write email_address through update_notifications
- web/db.py: get_error (no callers); drop kill_switch,
max_morning_commute, email_address from their allowed-sets so they're
not writable through update_* anymore
- web/settings.py + docker-compose.yml: SMTP_HOST/PORT/USERNAME/PASSWORD/
FROM/STARTTLS (notifications.py is telegram-only now)
DB columns themselves (kill_switch, email_address, max_morning_commute,
connectivity_morning_time, connectivity_night_time) stay in the schema
— SQLite can't drop them cheaply and they're harmless.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
63 lines
2.8 KiB
Python
63 lines
2.8 KiB
Python
import secrets
|
|
import sys
|
|
from os import getenv
|
|
from pathlib import Path
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
load_dotenv()
|
|
|
|
|
|
def _required(key: str) -> str:
|
|
val = getenv(key)
|
|
if not val:
|
|
print(f"missing required env var: {key}", file=sys.stderr)
|
|
sys.exit(1)
|
|
return val
|
|
|
|
|
|
# --- Admin bootstrap ----------------------------------------------------------
|
|
# On first boot the web service seeds this user as an admin in the database.
|
|
# Afterwards the user record in SQLite is authoritative: changing the hash in
|
|
# env does NOT rotate the DB password — use the /einstellungen UI.
|
|
AUTH_USERNAME: str = _required("AUTH_USERNAME")
|
|
AUTH_PASSWORD_HASH: str = _required("AUTH_PASSWORD_HASH")
|
|
|
|
# --- Session cookie -----------------------------------------------------------
|
|
SESSION_SECRET: str = getenv("SESSION_SECRET") or secrets.token_urlsafe(48)
|
|
SESSION_COOKIE_NAME: str = "wohnungsdidi_session"
|
|
SESSION_MAX_AGE_SECONDS: int = int(getenv("SESSION_MAX_AGE_SECONDS", str(60 * 60 * 24 * 7)))
|
|
COOKIE_SECURE: bool = getenv("COOKIE_SECURE", "true").lower() in ("true", "1", "yes", "on")
|
|
|
|
# --- Internal service auth ----------------------------------------------------
|
|
INTERNAL_API_KEY: str = _required("INTERNAL_API_KEY")
|
|
|
|
# --- Apply service ------------------------------------------------------------
|
|
APPLY_URL: str = getenv("APPLY_URL", "http://apply:8000")
|
|
APPLY_TIMEOUT: int = int(getenv("APPLY_TIMEOUT", "600"))
|
|
APPLY_FAILURE_THRESHOLD: int = int(getenv("APPLY_FAILURE_THRESHOLD", "3"))
|
|
|
|
# --- Alert service knob (mirrored so web can predict the next scrape) ---------
|
|
ALERT_SCRAPE_INTERVAL_SECONDS: int = int(getenv("ALERT_SCRAPE_INTERVAL_SECONDS", getenv("SLEEP_INTERVALL", "60")))
|
|
|
|
# --- Storage ------------------------------------------------------------------
|
|
DATA_DIR: Path = Path(getenv("DATA_DIR", "/data"))
|
|
DATA_DIR.mkdir(parents=True, exist_ok=True)
|
|
# Legacy filename — kept so existing data under /data/lazyflat.sqlite stays
|
|
# reachable across the rename to wohnungsdidi. Not user-facing.
|
|
DB_PATH: Path = DATA_DIR / "lazyflat.sqlite"
|
|
|
|
# Retention (errors / audit / application forensics). Default 14 days.
|
|
RETENTION_DAYS: int = int(getenv("RETENTION_DAYS", "14"))
|
|
RETENTION_RUN_INTERVAL_SECONDS: int = int(getenv("RETENTION_RUN_INTERVAL_SECONDS", str(60 * 60)))
|
|
|
|
# --- Rate limiting ------------------------------------------------------------
|
|
LOGIN_RATE_LIMIT: int = int(getenv("LOGIN_RATE_LIMIT", "5"))
|
|
LOGIN_RATE_WINDOW_SECONDS: int = int(getenv("LOGIN_RATE_WINDOW_SECONDS", "900"))
|
|
|
|
# --- App URL (used to build links in notifications) ---------------------------
|
|
PUBLIC_URL: str = getenv("PUBLIC_URL", "https://flat.lab.moritz.run")
|
|
|
|
# --- LLM enrichment (Anthropic Haiku) -----------------------------------------
|
|
ANTHROPIC_API_KEY: str = getenv("ANTHROPIC_API_KEY", "")
|
|
ANTHROPIC_MODEL: str = getenv("ANTHROPIC_MODEL", "claude-haiku-4-5-20251001")
|