.
This commit is contained in:
parent
6106b96a49
commit
aadb57588c
20
bots-common/request_issue.go
Normal file
20
bots-common/request_issue.go
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package common
|
||||||
|
|
||||||
|
type IssueDetail struct {
|
||||||
|
Id int
|
||||||
|
Number int
|
||||||
|
Html_url string
|
||||||
|
User *User
|
||||||
|
Title string
|
||||||
|
Body string
|
||||||
|
State string
|
||||||
|
}
|
||||||
|
|
||||||
|
type IssueWebhookEvent struct {
|
||||||
|
Action string
|
||||||
|
|
||||||
|
Issue *IssueDetail
|
||||||
|
Repository *Repository
|
||||||
|
Sender *User
|
||||||
|
}
|
||||||
|
|
@ -94,6 +94,22 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
|
|||||||
|
|
||||||
org = release.Repository.Owner
|
org = release.Repository.Owner
|
||||||
extraAction = release.Action
|
extraAction = release.Action
|
||||||
|
|
||||||
|
case "issues":
|
||||||
|
issue := common.IssueWebhookEvent{}
|
||||||
|
if err = json.Unmarshal(data, &issue); err != nil {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
switch issue.Action {
|
||||||
|
case "opened", "closed", "reopened", "edited":
|
||||||
|
break
|
||||||
|
default:
|
||||||
|
err = fmt.Errorf("Unknown Issue webhook action type: %s", issue.Action)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
org = issue.Repository.Owner
|
||||||
|
extraAction = issue.Action
|
||||||
|
|
||||||
default:
|
default:
|
||||||
err = fmt.Errorf("Unknown webhook request type: %s", reqType)
|
err = fmt.Errorf("Unknown webhook request type: %s", reqType)
|
||||||
}
|
}
|
||||||
@ -161,7 +177,9 @@ func main() {
|
|||||||
// write to file for review
|
// write to file for review
|
||||||
id++
|
id++
|
||||||
os.WriteFile("test_data."+fmt.Sprint(id), data, 0644)
|
os.WriteFile("test_data."+fmt.Sprint(id), data, 0644)
|
||||||
|
if org != nil {
|
||||||
log.Println(id, org.Username, reqType, extraAction)
|
log.Println(id, org.Username, reqType, extraAction)
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
err = PublishMessage(org.Name, reqType, extraAction, data)
|
err = PublishMessage(org.Name, reqType, extraAction, data)
|
||||||
|
Loading…
Reference in New Issue
Block a user