mirror of
https://github.com/R0m1k3/Priceflow.git
synced 2026-10-12 01:39:25 +02:00
feat: Implement a new notification service using Apprise for sending notifications via various channels.
This commit is contained in:
1 parent
7dfc9e1af3
commit
f720a7aa17
1 file changed
+9
-5
@@ -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
|
||||
|
||||
Reference in new issue
Block a user