feat: Implement a new notification service using Apprise for sending notifications via various channels.

This commit is contained in:
Michael committed 2025-11-23 23:42:00 +01:00
1 parent 7dfc9e1af3
commit f720a7aa17
1 file changed
+9 -5
+9 -5
View File
@@ -38,12 +38,8 @@ class NotificationService:
@staticmethod
def _get_config_url(channel: models.NotificationChannel) -> str | None:
"""Construct Apprise URL from channel configuration."""
# Try to parse as JSON first
try:
# If configuration is already a URL (e.g. for simple webhooks), use it
if channel.configuration.startswith("http") or "://" in channel.configuration:
return channel.configuration
# If it's JSON, parse it
config = json.loads(channel.configuration)
if channel.type == "email":
@@ -87,6 +83,14 @@ class NotificationService:
return None
except json.JSONDecodeError:
# If not JSON, check if it's a raw URL
if channel.configuration.startswith("http") or "://" in channel.configuration:
return channel.configuration
logger.error(f"Invalid configuration format for channel {channel.name}")
return None
except Exception as e:
logger.error(f"Error parsing configuration for channel {channel.name}: {e}")
return None