From f720a7aa17f0c904a884bc64c90eec39e50c0100 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Sun, 23 Nov 2025 23:42:00 +0100 Subject: [PATCH] feat: Implement a new notification service using Apprise for sending notifications via various channels. --- app/services/notification_service.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/app/services/notification_service.py b/app/services/notification_service.py index 5f8f422..c123714 100644 --- a/app/services/notification_service.py +++ b/app/services/notification_service.py @@ -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