20 lines
650 B
Python
20 lines
650 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": f"Bourbonacci Admin - {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)
|