Send notification on new user creations

This commit is contained in:
2022-12-18 17:49:42 +00:00
parent 8de99c1bcd
commit 50820172b1
2 changed files with 15 additions and 6 deletions

View File

@@ -8,7 +8,9 @@ log = logs.get_logger(__name__)
# Actual function to send a message to a topic
def _sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None):
def raw_sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None):
if url is None:
url = NTFY_URL
headers = {"Title": "Fisk"}
if title:
headers["Title"] = title
@@ -26,10 +28,6 @@ def _sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None):
# Sendmsg helper to send a message to a user's notification settings
def sendmsg(user, *args, **kwargs):
notification_settings = user.get_notification_settings()
if notification_settings.ntfy_url is None:
url = NTFY_URL
else:
url = notification_settings.ntfy_url
if notification_settings.ntfy_topic is None:
# No topic set, so don't send
@@ -37,4 +35,4 @@ def sendmsg(user, *args, **kwargs):
else:
topic = notification_settings.ntfy_topic
_sendmsg(*args, **kwargs, url=url, topic=topic)
raw_sendmsg(*args, **kwargs, url=notification_settings.ntfy_url, topic=topic)