diff --git a/api/convert.go b/api/convert.go index cb2c748..a28166e 100644 --- a/api/convert.go +++ b/api/convert.go @@ -389,7 +389,7 @@ func countReaction(reactions []*gitea.Reaction, reactionType string) int { return count } -func translatePrAction(action structs.HookIssueAction) string { +func translatePrAction(action structs.HookIssueAction, prefix bool) string { translatedAction := "" switch action { @@ -429,7 +429,9 @@ func translatePrAction(action structs.HookIssueAction) string { translatedAction = "unknown_action" } - translatedAction = fmt.Sprintf("pull_request.%s", translatedAction) + if prefix { + translatedAction = fmt.Sprintf("pull_request.%s", translatedAction) + } return translatedAction } diff --git a/api/convert_event.go b/api/convert_event.go index cf0d402..b9943f9 100644 --- a/api/convert_event.go +++ b/api/convert_event.go @@ -15,7 +15,7 @@ func convertPullRequestEvent(event *structs.PullRequestPayload) *github.PullRequ } return &github.PullRequestEvent{ - Action: stringPtr(translatePrAction(event.Action)), + Action: stringPtr(translatePrAction(event.Action, false)), PullRequest: convertPullRequest(event.PullRequest), Repo: convertCoreRepo(event.Repository), Assignee: convertCoreUser(event.PullRequest.Assignee), diff --git a/api/webhook_manager.go b/api/webhook_manager.go index f8c72c2..1d2e478 100644 --- a/api/webhook_manager.go +++ b/api/webhook_manager.go @@ -30,7 +30,7 @@ func NewWebhookManager(cfg *config.Config, db *gorm.DB, logger *zap.Logger) *Web func (whm *WebhookManager) HandlePullRequest(request *giteaTypes.PullRequestPayload, r *http.Request) { ghEvent := convertPullRequestEvent(request) - githubAction := translatePrAction(request.Action) + githubAction := translatePrAction(request.Action, true) r.Header.Set("X-GitHub-Event", githubAction) whm.sendWebhooks(ghEvent, r)