forked from forgejo/forgejo
Move webhook to a standalone package under modules (#8747)
* Move webhook to a standalone package under modules * fix test * fix comments
This commit is contained in:
parent
ba336f6f45
commit
0e7f7df3cf
20 changed files with 570 additions and 478 deletions
|
@ -11,6 +11,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/git"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/webhook"
|
||||
issue_service "code.gitea.io/gitea/services/issue"
|
||||
)
|
||||
|
||||
|
@ -41,7 +42,7 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
|||
pr.Issue = pull
|
||||
pull.PullRequest = pr
|
||||
mode, _ := models.AccessLevel(pull.Poster, repo)
|
||||
if err := models.PrepareWebhooks(repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||
if err := webhook.PrepareWebhooks(repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||
Action: api.HookIssueOpened,
|
||||
Index: pull.Index,
|
||||
PullRequest: pr.APIFormat(),
|
||||
|
@ -50,7 +51,7 @@ func NewPullRequest(repo *models.Repository, pull *models.Issue, labelIDs []int6
|
|||
}); err != nil {
|
||||
log.Error("PrepareWebhooks: %v", err)
|
||||
} else {
|
||||
go models.HookQueue.Add(repo.ID)
|
||||
go webhook.HookQueue.Add(repo.ID)
|
||||
}
|
||||
|
||||
return nil
|
||||
|
@ -114,7 +115,7 @@ func AddTestPullRequestTask(doer *models.User, repoID int64, branch string, isSy
|
|||
log.Error("LoadAttributes: %v", err)
|
||||
continue
|
||||
}
|
||||
if err = models.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||
if err = webhook.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
|
||||
Action: api.HookIssueSynchronized,
|
||||
Index: pr.Issue.Index,
|
||||
PullRequest: pr.Issue.PullRequest.APIFormat(),
|
||||
|
@ -124,7 +125,7 @@ func AddTestPullRequestTask(doer *models.User, repoID int64, branch string, isSy
|
|||
log.Error("PrepareWebhooks [pull_id: %v]: %v", pr.ID, err)
|
||||
continue
|
||||
}
|
||||
go models.HookQueue.Add(pr.Issue.Repo.ID)
|
||||
go webhook.HookQueue.Add(pr.Issue.Repo.ID)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue