mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
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:
@@ -14,6 +14,7 @@ import (
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
api "code.gitea.io/gitea/modules/structs"
|
||||
"code.gitea.io/gitea/modules/webhook"
|
||||
)
|
||||
|
||||
// CommitRepoActionOptions represent options of a new commit action.
|
||||
@@ -112,7 +113,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
}
|
||||
|
||||
defer func() {
|
||||
go models.HookQueue.Add(repo.ID)
|
||||
go webhook.HookQueue.Add(repo.ID)
|
||||
}()
|
||||
|
||||
apiPusher := pusher.APIFormat()
|
||||
@@ -134,7 +135,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
if err != nil {
|
||||
log.Error("GetBranchCommitID[%s]: %v", opts.RefFullName, err)
|
||||
}
|
||||
if err = models.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||
if err = webhook.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||
Ref: refName,
|
||||
Sha: shaSum,
|
||||
RefType: "branch",
|
||||
@@ -148,7 +149,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
case models.ActionDeleteBranch: // Delete Branch
|
||||
isHookEventPush = true
|
||||
|
||||
if err = models.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||
if err = webhook.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||
Ref: refName,
|
||||
RefType: "branch",
|
||||
PusherType: api.PusherTypeUser,
|
||||
@@ -169,7 +170,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
if err != nil {
|
||||
log.Error("GetTagCommitID[%s]: %v", opts.RefFullName, err)
|
||||
}
|
||||
if err = models.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||
if err = webhook.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
|
||||
Ref: refName,
|
||||
Sha: shaSum,
|
||||
RefType: "tag",
|
||||
@@ -181,7 +182,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
case models.ActionDeleteTag: // Delete Tag
|
||||
isHookEventPush = true
|
||||
|
||||
if err = models.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||
if err = webhook.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
|
||||
Ref: refName,
|
||||
RefType: "tag",
|
||||
PusherType: api.PusherTypeUser,
|
||||
@@ -197,7 +198,7 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = models.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
||||
if err = webhook.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
|
||||
Ref: opts.RefFullName,
|
||||
Before: opts.OldCommitID,
|
||||
After: opts.NewCommitID,
|
||||
|
Reference in New Issue
Block a user