Planning/backend/core/notifications.py
Louis Mazin 09ff6dd430 init
2026-10-02 15:54:40 +02:00

17 lines
594 B
Python

import os, requests
def send_ntfy_notification(title, message, click_url=None):
topic = os.getenv("NTFY_TOPIC", "").strip()
if not topic:
return False
server = os.getenv("NTFY_SERVER", "https://ntfy.sh").rstrip("/")
headers = {"Title": title, "Priority": "high", "Tags": "calendar,question"}
if click_url:
headers["Click"] = click_url
try:
r = requests.post(f"{server}/{topic}", data=message.encode("utf-8"), headers=headers, timeout=8)
r.raise_for_status()
return True
except requests.RequestException:
return False