mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-26 18:55:44 +02:00
modify notification module config
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user