From 2a034a16e7d1e7d1bb0ce0a18bd759d7f8b4a94b Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Thu, 9 Feb 2023 07:20:07 +0000 Subject: [PATCH] Allow disabling notifications --- core/lib/notify.py | 3 +++ core/lib/rules.py | 3 +++ core/models.py | 1 + 3 files changed, 7 insertions(+) diff --git a/core/lib/notify.py b/core/lib/notify.py index 99188e9..45b366a 100644 --- a/core/lib/notify.py +++ b/core/lib/notify.py @@ -95,6 +95,9 @@ def sendmsg(**kwargs): return service = notification_settings.get("service") + if service == "none": + # Don't send anything + return if service == "ntfy": ntfy_sendmsg(**kwargs) diff --git a/core/lib/rules.py b/core/lib/rules.py index 2a83353..684d745 100644 --- a/core/lib/rules.py +++ b/core/lib/rules.py @@ -140,6 +140,9 @@ def rule_notify(rule, index, message, meta=None): if not notification_settings: # No/invalid notification settings, don't send anything return + if notification_settings.get("service") == "none": + # Don't send anything + return # Create a cast we can reuse for the formatting helpers and sendmsg cast = { diff --git a/core/models.py b/core/models.py index 092cfb3..8be3a41 100644 --- a/core/models.py +++ b/core/models.py @@ -39,6 +39,7 @@ INTERVAL_CHOICES = ( SERVICE_CHOICES = ( ("ntfy", "NTFY"), ("webhook", "Custom webhook"), + ("none", "Disabled"), )