From 57af3812c00c5bddba11ffb38ef711b7d63cc38e8a7e280cb01e397ad2390974 Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Mon, 26 Aug 2024 13:39:36 +0200 Subject: [PATCH] . --- gitea-events-rabbitmq-publisher/main.go | 30 ++++++++++++++++++------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/gitea-events-rabbitmq-publisher/main.go b/gitea-events-rabbitmq-publisher/main.go index 1ff8012..67a60aa 100644 --- a/gitea-events-rabbitmq-publisher/main.go +++ b/gitea-events-rabbitmq-publisher/main.go @@ -134,7 +134,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex case "edited", "created", "deleted": break 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 } org = issue.Repository.Owner @@ -239,27 +239,41 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex case "review_requested", "review_request_removed": break 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 } org = issue.Repository.Owner extraAction = issue.Action case "pull_request_review_rejected", "pull_request_review_approved": - issue := common.PullRequestWebhookEvent{} - if err = json.Unmarshal(data, &issue); err != nil { + pr := common.PullRequestWebhookEvent{} + if err = json.Unmarshal(data, &pr); err != nil { return } - switch issue.Action { + switch pr.Action { case "reviewed": break 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 } - org = issue.Repository.Owner - extraAction = issue.Action + org = pr.Repository.Owner + 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: // TODO: package and wiki