Skip to content

Commit

Permalink
Merge pull request #7 from Indicio-tech/fix/webhook-dataclass
Browse files Browse the repository at this point in the history
Fix issues with webhooks in 0.1.0
  • Loading branch information
dbluhm authored May 9, 2022
2 parents 86d9caf + 9a5be94 commit f550f15
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions echo_agent/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)

Expand All @@ -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."""
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit f550f15

Please sign in to comment.