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
|
return count
|
||||||
}
|
}
|
||||||
|
|
||||||
func translatePrAction(action structs.HookIssueAction) string {
|
func translatePrAction(action structs.HookIssueAction, prefix bool) string {
|
||||||
translatedAction := ""
|
translatedAction := ""
|
||||||
|
|
||||||
switch action {
|
switch action {
|
||||||
|
@ -429,7 +429,9 @@ func translatePrAction(action structs.HookIssueAction) string {
|
||||||
translatedAction = "unknown_action"
|
translatedAction = "unknown_action"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if prefix {
|
||||||
translatedAction = fmt.Sprintf("pull_request.%s", translatedAction)
|
translatedAction = fmt.Sprintf("pull_request.%s", translatedAction)
|
||||||
|
}
|
||||||
|
|
||||||
return translatedAction
|
return translatedAction
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ func convertPullRequestEvent(event *structs.PullRequestPayload) *github.PullRequ
|
||||||
}
|
}
|
||||||
|
|
||||||
return &github.PullRequestEvent{
|
return &github.PullRequestEvent{
|
||||||
Action: stringPtr(translatePrAction(event.Action)),
|
Action: stringPtr(translatePrAction(event.Action, false)),
|
||||||
PullRequest: convertPullRequest(event.PullRequest),
|
PullRequest: convertPullRequest(event.PullRequest),
|
||||||
Repo: convertCoreRepo(event.Repository),
|
Repo: convertCoreRepo(event.Repository),
|
||||||
Assignee: convertCoreUser(event.PullRequest.Assignee),
|
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) {
|
func (whm *WebhookManager) HandlePullRequest(request *giteaTypes.PullRequestPayload, r *http.Request) {
|
||||||
ghEvent := convertPullRequestEvent(request)
|
ghEvent := convertPullRequestEvent(request)
|
||||||
githubAction := translatePrAction(request.Action)
|
githubAction := translatePrAction(request.Action, true)
|
||||||
r.Header.Set("X-GitHub-Event", githubAction)
|
r.Header.Set("X-GitHub-Event", githubAction)
|
||||||
|
|
||||||
whm.sendWebhooks(ghEvent, r)
|
whm.sendWebhooks(ghEvent, r)
|
||||||
|
|
Loading…
Reference in New Issue