From 2e2cf023c691b9dc128171a49335b1d87eaab8a2564d581e485c154277af727e Mon Sep 17 00:00:00 2001 From: Adam Majer Date: Mon, 26 Aug 2024 17:30:36 +0200 Subject: [PATCH] . --- bots-common/listen.go | 11 +++++++++-- gitea-events-rabbitmq-publisher/main.go | 14 +++++++------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/bots-common/listen.go b/bots-common/listen.go index 6bc7e0f..7309435 100644 --- a/bots-common/listen.go +++ b/bots-common/listen.go @@ -18,8 +18,15 @@ const RequestType_Push = "push" const RequestType_Repository = "repository" const RequestType_Release = "release" const RequestType_PR = "pull_request" +const RequestType_PRAssign = "pull_request_assign" +const ReqeustType_PRLabel = "pull_request_label" const RequestType_PRComment = "pull_request_comment" -const RequestType_PR_sync = "pull_request_sync" +const RequestType_PRMilestone = "pull_request_milestone" +const RequestType_PRSync = "pull_request_sync" +const RequestType_PRReviewAccepted = "pull_request_review_approved" +const RequestType_PRReviewRejected = "pull_request_review_rejected" +const RequestType_PRReviewRequest = "pull_request_review_request" +const RequestType_Wiki = "wiki" type RequestProcessor func(*RequestHandler) error @@ -66,7 +73,7 @@ func StartServerWithAddress(listenDefs ListenDefinitions, addr string) { h.parsePushRequest(req.Body) case RequestType_PR: h.parsePullRequest(req.Body) - case RequestType_PR_sync: + case RequestType_PRSync: h.parsePullRequestSync(req.Body) default: h.ErrLogger.Printf("Unhandled request type: %s\n", reqType) diff --git a/gitea-events-rabbitmq-publisher/main.go b/gitea-events-rabbitmq-publisher/main.go index 3009819..22127be 100644 --- a/gitea-events-rabbitmq-publisher/main.go +++ b/gitea-events-rabbitmq-publisher/main.go @@ -185,7 +185,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = pr.Repository.Owner extraAction = pr.Action - case "pull_request_label": + case common.RequestType_PRLabel: pr := common.PullRequestWebhookEvent{} if err = json.Unmarshal(data, &pr); err != nil { return @@ -200,7 +200,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = pr.Repository.Owner extraAction = pr.Action - case "pull_request_milestone": + case common.RequestType_PRMilestone: pr := common.PullRequestWebhookEvent{} if err = json.Unmarshal(data, &pr); err != nil { return @@ -215,7 +215,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = pr.Repository.Owner extraAction = pr.Action - case "pull_request_assign": + case common.RequestType_PRAssign: issue := common.PullRequestWebhookEvent{} if err = json.Unmarshal(data, &issue); err != nil { return @@ -230,7 +230,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = issue.Repository.Owner extraAction = issue.Action - case "pull_request_review_request": + case common.RequestType_PRReviewRequest: issue := common.PullRequestWebhookEvent{} if err = json.Unmarshal(data, &issue); err != nil { return @@ -245,7 +245,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = issue.Repository.Owner extraAction = issue.Action - case "pull_request_review_rejected", "pull_request_review_approved": + case common.RequestType_PRReviewAccepted, common.RequestType_PRReviewRejected: 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 common.RequestType_PR_sync: + case common.RequestType_PRSync: pr := common.PullRequestWebhookEvent{} if err = json.Unmarshal(data, &pr); err != nil { return @@ -275,7 +275,7 @@ func parseRequestJSON(reqType string, data []byte) (org *common.Organization, ex org = pr.Repository.Owner extraAction = "" - case "wiki": + case common.RequestType_Wiki: wiki := common.WikiWebhookEvent{} if err = json.Unmarshal(data, &wiki); err != nil { return