first commit
This commit is contained in:
commit
dc1245f164
22 changed files with 1666 additions and 0 deletions
41
notifications/sms.py
Normal file
41
notifications/sms.py
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
"""SMS notification provider stubs."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import os
|
||||
|
||||
from notifications.base import LoggingNotificationService, NotificationService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class SmsNotificationService(LoggingNotificationService):
|
||||
"""
|
||||
SMS notification service.
|
||||
|
||||
Currently logs messages. Future providers (Twilio, Urmi, etc.) can be
|
||||
plugged in without changing the monitoring engine.
|
||||
"""
|
||||
|
||||
def __init__(self) -> None:
|
||||
self.provider = os.environ.get("SMS_PROVIDER", "logging")
|
||||
self.api_key = os.environ.get("SMS_API_KEY", "")
|
||||
self.from_number = os.environ.get("SMS_FROM_NUMBER", "")
|
||||
self.to_number = os.environ.get("SMS_TO_NUMBER", "")
|
||||
|
||||
def send_sms(self, message: str) -> bool:
|
||||
if self.provider == "logging" or not self.api_key:
|
||||
return super().send_sms(message)
|
||||
|
||||
# Placeholder for future provider integration
|
||||
logger.warning(
|
||||
"SMS provider '%s' is not yet implemented; logging instead",
|
||||
self.provider,
|
||||
)
|
||||
return super().send_sms(message)
|
||||
|
||||
|
||||
def create_sms_service() -> NotificationService:
|
||||
"""Factory for SMS-capable notification service."""
|
||||
return SmsNotificationService()
|
||||
Loading…
Add table
Add a link
Reference in a new issue