e08e031ad0
- nginx: add HSTS (max-age=31536000) and gzip for text/css/js/json - entries: add limit/offset query params (default 200, max 1000) - Ntfy: wire NTFY_URL/NTFY_TOKEN through env; notify on startup, new registration, admin login, user disable, and user delete - httpx==0.28.1 added for async Ntfy HTTP calls Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
20 lines
625 B
Python
20 lines
625 B
Python
import logging
|
|
import httpx
|
|
|
|
from app.config import settings
|
|
|
|
logger = logging.getLogger("bourbonacci.notify")
|
|
|
|
|
|
async def notify(title: str, message: str, priority: str = "default") -> None:
|
|
if not settings.ntfy_url:
|
|
return
|
|
headers = {"Title": title, "Priority": priority}
|
|
if settings.ntfy_token:
|
|
headers["Authorization"] = f"Bearer {settings.ntfy_token}"
|
|
try:
|
|
async with httpx.AsyncClient(timeout=5) as client:
|
|
await client.post(settings.ntfy_url, content=message, headers=headers)
|
|
except Exception as exc:
|
|
logger.warning("Ntfy notification failed: %s", exc)
|