mirror of
https://github.com/maxdorninger/MediaManager.git
synced 2026-04-17 15:43:28 +02:00
This PR enables the ruff rule for return type annotations (ANN), and adds the ty package for type checking.
30 lines
944 B
Python
30 lines
944 B
Python
import requests
|
|
|
|
from media_manager.config import MediaManagerConfig
|
|
from media_manager.notification.schemas import MessageNotification
|
|
from media_manager.notification.service_providers.abstract_notification_service_provider import (
|
|
AbstractNotificationServiceProvider,
|
|
)
|
|
|
|
|
|
class GotifyNotificationServiceProvider(AbstractNotificationServiceProvider):
|
|
"""
|
|
Gotify Notification Service Provider
|
|
"""
|
|
|
|
def __init__(self) -> None:
|
|
self.config = MediaManagerConfig().notifications.gotify
|
|
|
|
def send_notification(self, message: MessageNotification) -> bool:
|
|
response = requests.post(
|
|
url=f"{self.config.url}/message?token={self.config.api_key}",
|
|
json={
|
|
"message": message.message,
|
|
"title": message.title,
|
|
},
|
|
timeout=60,
|
|
)
|
|
if response.status_code not in range(200, 300):
|
|
return False
|
|
return True
|