modify notification module config

This commit is contained in:
maxDorninger
2025-07-10 23:48:29 +02:00
parent 8a89a24f25
commit d986f91e5e
6 changed files with 52 additions and 22 deletions

View File

@@ -1,10 +1,18 @@
import requests
from pydantic_settings import BaseSettings
from media_manager.config import AllEncompassingConfig
from media_manager.notification.schemas import MessageNotification
from media_manager.notification.service_providers.abstractNotificationServiceProvider import (
AbstractNotificationServiceProvider,
)
class GotifyConfig(BaseSettings):
enabled: bool = False
api_key: str | None = None
url: str | None = (
None # e.g. https://gotify.example.com (note lack of trailing slash)
)
class GotifyNotificationServiceProvider(AbstractNotificationServiceProvider):
"""
@@ -12,11 +20,11 @@ class GotifyNotificationServiceProvider(AbstractNotificationServiceProvider):
"""
def __init__(self):
self.config = AllEncompassingConfig().notifications
self.config = AllEncompassingConfig().notifications.gotify
def send_notification(self, message: MessageNotification) -> bool:
response = requests.post(
url=f"{self.config.gotify_url}/message?token={self.config.gotify_api_key}",
url=f"{self.config.url}/message?token={self.config.api_key}",
json={
"message": message.message,
"title": message.title,