This commit is contained in:
Adam Majer 2024-08-24 18:15:53 +02:00
parent 1db814b5d3
commit 87ab2e0af5
2 changed files with 21 additions and 4 deletions

View File

@ -839,3 +839,5 @@ const createTagJSON=`{
"username": "adamm"
}
}`

View File

@ -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)