This commit is contained in:
Adam Majer 2024-08-26 13:39:36 +02:00
parent 4146290df8
commit 57af3812c0

View File

@ -134,7 +134,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
case "edited", "created", "deleted": case "edited", "created", "deleted":
break break
default: default:
err = fmt.Errorf("Unknown Issue Comment webhook action type: %s", issue.Action) err = fmt.Errorf("Unknown Issue/PR Comment webhook action type: %s", issue.Action)
return return
} }
org = issue.Repository.Owner org = issue.Repository.Owner
@ -239,27 +239,41 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex
case "review_requested", "review_request_removed": case "review_requested", "review_request_removed":
break break
default: default:
err = fmt.Errorf("Unknown PR Assign webhook action type: %s", issue.Action) err = fmt.Errorf("Unknown PR Review Request webhook action type: %s", issue.Action)
return return
} }
org = issue.Repository.Owner org = issue.Repository.Owner
extraAction = issue.Action extraAction = issue.Action
case "pull_request_review_rejected", "pull_request_review_approved": case "pull_request_review_rejected", "pull_request_review_approved":
issue := common.PullRequestWebhookEvent{} pr := common.PullRequestWebhookEvent{}
if err = json.Unmarshal(data, &issue); err != nil { if err = json.Unmarshal(data, &pr); err != nil {
return return
} }
switch issue.Action { switch pr.Action {
case "reviewed": case "reviewed":
break break
default: default:
err = fmt.Errorf("Unknown PR Assign webhook action type: %s", issue.Action) err = fmt.Errorf("Unknown PR Review webhook action type: %s", pr.Action)
return return
} }
org = issue.Repository.Owner org = pr.Repository.Owner
extraAction = issue.Action extraAction = ""
case "pull_request_sync":
pr := common.PullRequestWebhookEvent{}
if err = json.Unmarshal(data, &pr); err != nil {
return
}
switch pr.Action {
case "synchronized":
break
default:
err = fmt.Errorf("Unknown PR Sync webhook action type: %s", pr.Action)
return
}
org = pr.Repository.Owner
extraAction = ""
default: default:
// TODO: package and wiki // TODO: package and wiki