Allow overriding topic
This commit is contained in:
@@ -29,10 +29,11 @@ def raw_sendmsg(msg, title=None, priority=None, tags=None, url=None, topic=None)
|
||||
def sendmsg(user, *args, **kwargs):
|
||||
notification_settings = user.get_notification_settings()
|
||||
|
||||
if notification_settings.ntfy_topic is None:
|
||||
# No topic set, so don't send
|
||||
return
|
||||
else:
|
||||
topic = notification_settings.ntfy_topic
|
||||
if "topic" not in kwargs:
|
||||
if notification_settings.ntfy_topic is None:
|
||||
# No topic set, so don't send
|
||||
return
|
||||
else:
|
||||
kwargs["topic"] = notification_settings.ntfy_topic
|
||||
|
||||
raw_sendmsg(*args, **kwargs, url=notification_settings.ntfy_url, topic=topic)
|
||||
raw_sendmsg(*args, **kwargs, url=notification_settings.ntfy_url)
|
||||
|
||||
@@ -26,7 +26,14 @@ def rule_matched(rule, message, matched_fields):
|
||||
|
||||
notify_message = f"{rule.name} matched on {matched_fields}\n{message}"
|
||||
notify_message = notify_message.encode("utf-8", "replace")
|
||||
sendmsg(rule.user, notify_message, title=title, priority=str(rule.priority))
|
||||
|
||||
cast = {
|
||||
"title": title,
|
||||
"priority": str(rule.priority),
|
||||
}
|
||||
if rule.topic is not None:
|
||||
cast["topic"] = rule.topic
|
||||
sendmsg(rule.user, notify_message, **cast)
|
||||
|
||||
|
||||
def process_rules(data):
|
||||
|
||||
Reference in New Issue
Block a user