Skip to content

Commit

Permalink
improve subject
Browse files Browse the repository at this point in the history
  • Loading branch information
FelixTJDietrich committed Aug 20, 2024
1 parent 7de69ea commit cbd89be
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions server/webhook-ingest/app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,16 @@ async def github_webhook(

# Extract subject from the payload
payload = await request.json()
subject = ""

org = "?"
repo = "?"
if "repository" in payload:
owner = payload["repository"]["owner"]["login"]
org = payload["repository"]["owner"]["login"]
repo = payload["repository"]["name"]
subject = f"github.{owner}.{repo}.{event_type}"
else:
subject = f"github.error.{event_type}"
elif "organization" in payload:
org = payload["organization"]["login"]

subject = f"github.{org}.{repo}.{event_type}"

# Publish the payload to NATS JetStream
await nats_client.js.publish(subject, body)
Expand Down

0 comments on commit cbd89be

Please sign in to comment.