Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issues with webhooks in 0.1.0 #7

Merged
merged 2 commits into from
May 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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