from __future__ import annotations

import os

from .models import AlertEvent
from .notification_router import NotificationRouter


class RoutedNtfyNotifier:
    """Notifier compatible with HanzRealtimeService."""

    def __init__(self, router: NotificationRouter | None = None) -> None:
        self.router = router or NotificationRouter(
            server_url=os.getenv("HANZ_NTFY_SERVER", "https://ntfy.sh"),
            base_topic=os.getenv("HANZ_NTFY_BASE_TOPIC", ""),
            token=os.getenv("HANZ_NTFY_TOKEN") or None,
            dashboard_url=os.getenv(
                "HANZ_DASHBOARD_URL",
                "https://fazabihandoko28.github.io/",
            ),
        )

    def send(self, event: AlertEvent) -> bool:
        return self.router.send(event)
