From cbd89be6d51ca594a9386008256518fa2b8f0ee9 Mon Sep 17 00:00:00 2001 From: "Felix T.J. Dietrich" Date: Tue, 20 Aug 2024 17:54:18 +0200 Subject: [PATCH] improve subject --- server/webhook-ingest/app/main.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/webhook-ingest/app/main.py b/server/webhook-ingest/app/main.py index 7b5a708a..68874657 100644 --- a/server/webhook-ingest/app/main.py +++ b/server/webhook-ingest/app/main.py @@ -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)