.
This commit is contained in:
@@ -1,10 +1,11 @@
|
||||
import logging
|
||||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends, HTTPException
|
||||
|
||||
from ..models.notification import ExternalNotificationRequest
|
||||
from ..services.notification_manager import NotificationManagerService
|
||||
from ..dependencies import get_notification_manager
|
||||
|
||||
from capa_de_integracion.dependencies import get_notification_manager
|
||||
from capa_de_integracion.models.notification import ExternalNotificationRequest
|
||||
from capa_de_integracion.services.notification_manager import NotificationManagerService
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
router = APIRouter(prefix="/api/v1/dialogflow", tags=["notifications"])
|
||||
@@ -13,12 +14,11 @@ router = APIRouter(prefix="/api/v1/dialogflow", tags=["notifications"])
|
||||
@router.post("/notification", status_code=200)
|
||||
async def process_notification(
|
||||
request: ExternalNotificationRequest,
|
||||
notification_manager: NotificationManagerService = Depends(
|
||||
get_notification_manager
|
||||
),
|
||||
notification_manager: Annotated[NotificationManagerService, Depends(
|
||||
get_notification_manager,
|
||||
)],
|
||||
) -> None:
|
||||
"""
|
||||
Process push notification from external system.
|
||||
"""Process push notification from external system.
|
||||
|
||||
This endpoint receives notifications (e.g., "Your card was blocked") and:
|
||||
1. Stores them in Redis/Firestore
|
||||
@@ -37,6 +37,7 @@ async def process_notification(
|
||||
|
||||
Raises:
|
||||
HTTPException: 400 if validation fails, 500 for internal errors
|
||||
|
||||
"""
|
||||
try:
|
||||
logger.info("Received notification request")
|
||||
@@ -45,9 +46,9 @@ async def process_notification(
|
||||
# Match Java behavior: process but don't return response body
|
||||
|
||||
except ValueError as e:
|
||||
logger.error(f"Validation error: {str(e)}", exc_info=True)
|
||||
logger.error(f"Validation error: {e!s}", exc_info=True)
|
||||
raise HTTPException(status_code=400, detail=str(e))
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Error processing notification: {str(e)}", exc_info=True)
|
||||
logger.error(f"Error processing notification: {e!s}", exc_info=True)
|
||||
raise HTTPException(status_code=500, detail="Internal server error")
|
||||
|
||||
Reference in New Issue
Block a user