This commit is contained in:
2024-08-26 17:07:52 +02:00
parent 0473ef7c37
commit 3df22a72bb
5 changed files with 38 additions and 19 deletions

View File

@@ -43,28 +43,28 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
extraAction = ""
switch reqType {
case "create", "delete":
case common.RequestType_CreateBrachTag, common.RequestType_DeleteBranchTag:
create := common.CreateWebhookEvent{}
if err = json.Unmarshal(data, &create); err != nil {
return
}
org = create.Repository.Owner
case "fork":
case common.RequestType_Fork:
fork := common.ForkWebhookEvent{}
if err = json.Unmarshal(data, &fork); err != nil {
return
}
org = fork.Forkee.Owner
case "push":
case common.RequestType_Push:
push := common.PushRequest{}
if err = json.Unmarshal(data, &push); err != nil {
return
}
org = push.Repository.Owner
case "repository":
case common.RequestType_Repository:
repoAction := common.RepositoryAction{}
if err = json.Unmarshal(data, &repoAction); err != nil {
return
@@ -79,7 +79,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = repoAction.Organization
extraAction = repoAction.Action
case "release":
case common.RequestType_Release:
release := common.ReleaseWebhookEvent{}
if err = json.Unmarshal(data, &release); err != nil {
return
@@ -95,7 +95,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = release.Repository.Owner
extraAction = release.Action
case "issues":
case common.RequestType_Issue:
issue := common.IssueWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil {
return
@@ -110,7 +110,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = issue.Repository.Owner
extraAction = issue.Action
case "issue_assign":
case common.RequestType_IssueAssign:
issue := common.IssueWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil {
return
@@ -125,7 +125,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = issue.Repository.Owner
extraAction = issue.Action
case "issue_comment", "pull_request_comment":
case common.RequestType_IssueComment, common.RequestType_PRComment:
issue := common.IssueCommentWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil {
return
@@ -140,7 +140,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = issue.Repository.Owner
extraAction = issue.Action
case "issue_label":
case common.RequestType_IssueLabel:
issue := common.IssueWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil {
return
@@ -155,7 +155,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = issue.Repository.Owner
extraAction = issue.Action
case "issue_milestone":
case common.RequestType_IssueMilestone:
issue := common.IssueWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil {
return
@@ -170,7 +170,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = issue.Repository.Owner
extraAction = issue.Action
case "pull_request":
case common.RequestType_PR:
pr := common.PullRequestWebhookEvent{}
if err = json.Unmarshal(data, &pr); err != nil {
return
@@ -260,7 +260,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
org = pr.Repository.Owner
extraAction = ""
case "pull_request_sync":
case common.RequestType_PR_sync:
pr := common.PullRequestWebhookEvent{}
if err = json.Unmarshal(data, &pr); err != nil {
return