From 87ab2e0af54bfad708dea1c1f9a099b2bd5352b0ae5935f0f44179445c21afc7 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Sat, 24 Aug 2024 18:15:53 +0200 Subject: [PATCH] . --- bots-common/conststring_test.go | 2 ++ gitea-events-rabbitmq-publisher/main.go | 23 +++++++++++++++++++---- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/bots-common/conststring_test.go b/bots-common/conststring_test.go index a9ef061..3bd8784 100644 --- a/bots-common/conststring_test.go +++ b/bots-common/conststring_test.go @@ -839,3 +839,5 @@ const createTagJSON=`{ "username": "adamm" } }` + + diff --git a/gitea-events-rabbitmq-publisher/main.go b/gitea-events-rabbitmq-publisher/main.go index cf637f8..29ae23c 100644 --- a/gitea-events-rabbitmq-publisher/main.go +++ b/gitea-events-rabbitmq-publisher/main.go @@ -88,7 +88,9 @@ func main() { res.WriteHeader(http.StatusBadRequest) } -// repo := common.Repository{} + org := common.Organization{} + extraAction := "" + switch reqType { case "create", "delete": create := common.CreateWebhookEvent{} @@ -99,7 +101,8 @@ func main() { } return } -// repo = create.Repository + org = *create.Repository.Owner + case "fork": fork := common.ForkWebhookEvent{} if err = json.Unmarshal(data, &fork); err != nil { @@ -109,7 +112,7 @@ func main() { } return } -// repo = fork.Forkee + org = *fork.Forkee.Owner case "push": push := common.PushRequest{} if err = json.Unmarshal(data, &push); err != nil { @@ -119,13 +122,25 @@ func main() { } return } -// repo = push.Repository + org = *push.Repository.Owner + case "repository": + repoAction := common.RepositoryAction{} + if err = json.Unmarshal(data, &repoAction); err != nil { + res.WriteHeader(http.StatusBadRequest) + if DebugMode { + dumpUnhandledData(reqType, data) + } + return + } + org = repoAction.Organization + extraAction = repoAction.Action } // err = PublishMessage(repo.Owner.Username, reqType, data) // write to file for review os.WriteFile("test_data."+fmt.Sprint(connectionId), data, 0644) connectionId++ + log.Println(id, org.Username, extraAction) /* err = PublishMessage(repo.Name, reqType, data)