.
This commit is contained in:
parent
3a869126e7
commit
1db814b5d3
@ -1,6 +1,6 @@
|
||||
package common
|
||||
|
||||
type CreateWebhook struct {
|
||||
type CreateWebhookEvent struct {
|
||||
Sha string
|
||||
Ref string // name of tag/branch
|
||||
Ref_type string // tag, branch
|
||||
|
7
bots-common/request_fork.go
Normal file
7
bots-common/request_fork.go
Normal file
@ -0,0 +1,7 @@
|
||||
package common
|
||||
|
||||
type ForkWebhookEvent struct {
|
||||
Forkee Repository
|
||||
Repository
|
||||
Sender User
|
||||
}
|
@ -91,14 +91,35 @@ func main() {
|
||||
// repo := common.Repository{}
|
||||
switch reqType {
|
||||
case "create", "delete":
|
||||
create := common.CreateWebhook{}
|
||||
create := common.CreateWebhookEvent{}
|
||||
if err = json.Unmarshal(data, &create); err != nil {
|
||||
res.WriteHeader(http.StatusBadRequest)
|
||||
if DebugMode {
|
||||
dumpUnhandledData(reqType, data)
|
||||
}
|
||||
return
|
||||
}
|
||||
// repo = create.Repository
|
||||
case "fork":
|
||||
fork := common.ForkWebhookEvent{}
|
||||
if err = json.Unmarshal(data, &fork); err != nil {
|
||||
res.WriteHeader(http.StatusBadRequest)
|
||||
if DebugMode {
|
||||
dumpUnhandledData(reqType, data)
|
||||
}
|
||||
return
|
||||
}
|
||||
// repo = fork.Forkee
|
||||
case "push":
|
||||
push := common.PushRequest{}
|
||||
if err = json.Unmarshal(data, &push); err != nil {
|
||||
res.WriteHeader(http.StatusBadRequest)
|
||||
if DebugMode {
|
||||
dumpUnhandledData(reqType, data)
|
||||
}
|
||||
return
|
||||
}
|
||||
// repo = push.Repository
|
||||
}
|
||||
|
||||
// err = PublishMessage(repo.Owner.Username, reqType, data)
|
||||
@ -107,7 +128,7 @@ func main() {
|
||||
connectionId++
|
||||
|
||||
/*
|
||||
err = PublishMessage(reqType, req.PathValue("Org"), data)
|
||||
err = PublishMessage(repo.Name, reqType, data)
|
||||
if err != nil {
|
||||
errorStr := fmt.Sprintf("hook (%s) processing error: %v\n", reqType, err)
|
||||
res.Header().Add("Content-Type", "plain/text")
|
||||
|
Loading…
Reference in New Issue
Block a user