import logging import httpx from app.config import get_settings logger = logging.getLogger("homeschool.ntfy") async def notify(title: str, message: str, priority: str = "default", tags: list[str] | None = None) -> None: """Fire-and-forget notification to Ntfy. Silently logs errors — never raises.""" settings = get_settings() if not settings.ntfy_url: return headers = {"Title": title, "Priority": priority} if tags: headers["Tags"] = ",".join(tags) if settings.ntfy_token: headers["Authorization"] = f"Bearer {settings.ntfy_token}" try: async with httpx.AsyncClient(timeout=5) as client: resp = await client.post(settings.ntfy_url, content=message, headers=headers) resp.raise_for_status() except Exception as exc: logger.warning("Ntfy notification failed: %s", exc)