From 7dfc9e1af3633025f1544cd217eae310c241e627 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Sun, 23 Nov 2025 23:36:26 +0100 Subject: [PATCH] feat: Add notification service to send messages via Apprise with support for various channels. --- app/services/notification_service.py | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/app/services/notification_service.py b/app/services/notification_service.py index 6141fae..5f8f422 100644 --- a/app/services/notification_service.py +++ b/app/services/notification_service.py @@ -64,9 +64,26 @@ class NotificationService: return config.get("webhook_url") elif channel.type == "mattermost": - # mattermost://hostname/token - # Or the full webhook URL - return config.get("webhook_url") + webhook_url = config.get("webhook_url", "") + if not webhook_url: + return None + + # If it's already a mattermost:// URL, return it + if webhook_url.startswith("mattermost://"): + return webhook_url + + # Parse standard webhook URL: https://mattermost.example.com/hooks/TOKEN + try: + from urllib.parse import urlparse + parsed = urlparse(webhook_url) + path_parts = parsed.path.strip('/').split('/') + token = path_parts[-1] + host = parsed.netloc + + # Apprise format: mattermost://host/token + return f"mattermost://{host}/{token}" + except Exception: + return webhook_url return None