"""Resolves a NotificationType to a concrete provider. Console is always available and never costs anything; email/SMS are only meaningfully configured when their settings are present (callers gate on NOTIFICATION_SMS_ENABLED before ever routing to SMS - see alert_service.py). SMS has two interchangeable vendor providers (`SMS_PROVIDER=twilio|telnyx`), same pattern as LLM_PROVIDER/SEARCH_PROVIDER elsewhere in the app - swapping the setting changes which class this returns and nothing else has to change. """ from __future__ import annotations from app.core.config import Settings from app.models.enums import NotificationType from app.notifications.base import NotificationProvider from app.notifications.console import ConsoleProvider from app.notifications.smtp_email import SmtpEmailProvider from app.notifications.telnyx_sms import TelnyxSmsProvider from app.notifications.twilio_sms import TwilioSmsProvider def get_notification_provider( notification_type: NotificationType, settings: Settings ) -> NotificationProvider: if notification_type == NotificationType.EMAIL: return SmtpEmailProvider(settings) if notification_type == NotificationType.SMS: if settings.sms_provider == "telnyx": return TelnyxSmsProvider(settings) return TwilioSmsProvider(settings) return ConsoleProvider()