Implement notifications

This commit is contained in:
2022-12-18 16:55:09 +00:00
parent f4772a3c7d
commit 4c463e88f2
3 changed files with 36 additions and 1 deletions

23
core/lib/notify.py Normal file
View File

@@ -0,0 +1,23 @@
import requests
from django.conf import settings
from core.util import logs
NTFY_URL = "https://ntfy.sh"
log = logs.get_logger(__name__)
def sendmsg(msg, title=None, priority=None, tags=None):
headers = {"Title": "Fisk"}
if title:
headers["Title"] = title
if priority:
headers["Priority"] = priority
if tags:
headers["Tags"] = tags
requests.post(
f"{NTFY_URL}/{settings.NOTIFY_TOPIC}",
data=msg,
headers=headers,
)