diff --git a/echo_agent/app.py b/echo_agent/app.py index 10d5cce..2ab019a 100644 --- a/echo_agent/app.py +++ b/echo_agent/app.py @@ -35,9 +35,13 @@ NewConnection, ConnectionInfo as ConnectionInfoDataclass, SessionInfo, - Webhook, + Webhook as WebhookDataclass, ) +# Dataclass to Pydantic conversion +ConnectionInfo = dataclasses.dataclass(ConnectionInfoDataclass) +Webhook = dataclasses.dataclass(WebhookDataclass) + # Logging LOGGER = logging.getLogger("uvicorn.error." + __name__) @@ -57,9 +61,6 @@ async def setup_webhook_queue(): await webhooks.setup() -ConnectionInfo = dataclasses.dataclass(ConnectionInfoDataclass) - - @app.post("/connection", response_model=ConnectionInfo, operation_id="new_connection") async def new_connection(new_connection: NewConnection): """Create a new static connection.""" @@ -279,7 +280,9 @@ async def send_message_to_session(session_id: str, message: dict = Body(...)): async def receive_webhook(topic: str, payload: dict = Body(...)): """Receive a webhook.""" LOGGER.debug("Received webhook: topic %s, payload %s", topic, payload) - await webhooks.put(Webhook(topic, payload)) + webhook = Webhook(topic, payload) + await webhooks.put(webhook) + return webhook @app.get(