fix: prefix webhook action in header bot not the payload
This commit is contained in:
parent
7453fa48ee
commit
6aed2bfaae
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue