chore: remove redundant check
This commit is contained in:
@@ -3,9 +3,8 @@ import json
|
||||
import logging
|
||||
|
||||
import zmq.asyncio
|
||||
from fastapi import APIRouter, HTTPException, Request
|
||||
from fastapi import APIRouter, Request
|
||||
from fastapi.responses import StreamingResponse
|
||||
from pydantic import ValidationError
|
||||
from zmq.asyncio import Context, Socket
|
||||
|
||||
from control_backend.core.config import settings
|
||||
@@ -28,18 +27,10 @@ async def receive_command_speech(command: SpeechCommand, request: Request):
|
||||
:param command: The speech command payload.
|
||||
:param request: The FastAPI request object.
|
||||
"""
|
||||
# Validate and retrieve data.
|
||||
try:
|
||||
validated = SpeechCommand.model_validate(command)
|
||||
except ValidationError as e:
|
||||
raise HTTPException(
|
||||
status_code=422, detail=f"Payload is not valid SpeechCommand: {e}"
|
||||
) from e
|
||||
|
||||
topic = b"command"
|
||||
|
||||
pub_socket: Socket = request.app.state.endpoints_pub_socket
|
||||
await pub_socket.send_multipart([topic, validated.model_dump_json().encode()])
|
||||
await pub_socket.send_multipart([topic, command.model_dump_json().encode()])
|
||||
|
||||
return {"status": "Speech command received"}
|
||||
|
||||
@@ -56,18 +47,10 @@ async def receive_command_gesture(command: GestureCommand, request: Request):
|
||||
:param command: The speech command payload.
|
||||
:param request: The FastAPI request object.
|
||||
"""
|
||||
# Validate and retrieve data.
|
||||
try:
|
||||
validated = GestureCommand.model_validate(command)
|
||||
except ValidationError as e:
|
||||
raise HTTPException(
|
||||
status_code=422, detail=f"Payload is not valid GestureCommand: {e}"
|
||||
) from e
|
||||
|
||||
topic = b"command"
|
||||
|
||||
pub_socket: Socket = request.app.state.endpoints_pub_socket
|
||||
await pub_socket.send_multipart([topic, validated.model_dump_json().encode()])
|
||||
await pub_socket.send_multipart([topic, command.model_dump_json().encode()])
|
||||
|
||||
return {"status": "Gesture command received"}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user