* DB: users + user_profiles/filters/notifications/preferences; applications gets user_id + forensics_json + profile_snapshot_json; new errors table with 14d retention; schema versioning via MIGRATIONS list * auth: password hashes in DB (argon2); env vars seed first admin; per-user sessions; CSRF bound to user id * apply: personal info/WBS moved out of env into the request body; providers take an ApplyContext with Profile + submit_forms; full Playwright recorder (step log, console, page errors, network, screenshots, final HTML) * web: five top-level tabs (Wohnungen/Bewerbungen/Logs/Fehler/Einstellungen); settings sub-tabs profil/filter/benachrichtigungen/account/benutzer; per-user matching, auto-apply and notifications (UI/Telegram/SMTP); red auto-apply switch on Wohnungen tab; forensics detail view for bewerbungen and fehler; retention background thread Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
56 lines
1.8 KiB
Python
56 lines
1.8 KiB
Python
"""
|
|
apply service config.
|
|
|
|
Personal info and WBS fields used to live here as env vars; they now come in
|
|
with every /apply request as a Profile. The only remaining settings are
|
|
browser + service-level knobs.
|
|
"""
|
|
import logging
|
|
import sys
|
|
from os import getenv
|
|
from dotenv import load_dotenv
|
|
|
|
logger = logging.getLogger("flat-apply")
|
|
|
|
load_dotenv()
|
|
|
|
|
|
def get_env_or_fail(key: str, default: str | None = None, required: bool = True) -> str:
|
|
value = getenv(key, default)
|
|
if required and value is None:
|
|
logger.error(f"Missing required environment variable: {key}")
|
|
sys.exit(1)
|
|
return value
|
|
|
|
|
|
def get_bool_env(key: str, default: str = "False") -> bool:
|
|
return (getenv(key, default) or "").lower() in ("true", "1", "yes", "on")
|
|
|
|
|
|
def get_int_env(key: str, default: str) -> int:
|
|
v = getenv(key, default) or default
|
|
try:
|
|
return int(v)
|
|
except ValueError:
|
|
logger.error(f"Env var {key} must be int, got {v!r}")
|
|
sys.exit(1)
|
|
|
|
|
|
# --- Browser -----------------------------------------------------------------
|
|
HEADLESS: bool = get_bool_env("HEADLESS", "True")
|
|
BROWSER_WIDTH: int = get_int_env("BROWSER_WIDTH", "600")
|
|
BROWSER_HEIGHT: int = get_int_env("BROWSER_HEIGHT", "800")
|
|
BROWSER_LOCALE: str = getenv("BROWSER_LOCALE", "de-DE")
|
|
POST_SUBMISSION_SLEEP_MS: int = get_int_env("POST_SUBMISSION_SLEEP_MS", "0")
|
|
|
|
# --- Service -----------------------------------------------------------------
|
|
INTERNAL_API_KEY: str = get_env_or_fail("INTERNAL_API_KEY")
|
|
|
|
|
|
def log_settings() -> None:
|
|
logger.debug("--- Settings ---")
|
|
logger.debug(f"HEADLESS: {HEADLESS}")
|
|
logger.debug(f"BROWSER_WIDTH: {BROWSER_WIDTH}")
|
|
logger.debug(f"BROWSER_HEIGHT: {BROWSER_HEIGHT}")
|
|
logger.debug(f"BROWSER_LOCALE: {BROWSER_LOCALE}")
|
|
logger.debug(f"POST_SUBMISSION_SLEEP_MS: {POST_SUBMISSION_SLEEP_MS}")
|