1
1
mirror of https://github.com/go-gitea/gitea synced 2025-07-03 09:07:19 +00:00

Restructure webhook module (#22256)

Previously, there was an `import services/webhooks` inside
`modules/notification/webhook`.
This import was removed (after fighting against many import cycles).
Additionally, `modules/notification/webhook` was moved to
`modules/webhook`,
and a few structs/constants were extracted from `models/webhooks` to
`modules/webhook`.

Co-authored-by: 6543 <6543@obermui.de>
Co-authored-by: Lunny Xiao <xiaolunwen@gmail.com>
This commit is contained in:
delvh
2023-01-01 16:23:15 +01:00
committed by GitHub
parent f8e93ce423
commit 0f4e1b9ac6
37 changed files with 444 additions and 362 deletions

View File

@ -14,6 +14,7 @@ import (
"code.gitea.io/gitea/modules/setting"
api "code.gitea.io/gitea/modules/structs"
"code.gitea.io/gitea/modules/web"
webhook_module "code.gitea.io/gitea/modules/webhook"
"code.gitea.io/gitea/routers/api/v1/utils"
"code.gitea.io/gitea/services/convert"
webhook_service "code.gitea.io/gitea/services/webhook"
@ -68,7 +69,7 @@ func ListHooks(ctx *context.APIContext) {
apiHooks := make([]*api.Hook, len(hooks))
for i := range hooks {
apiHooks[i], err = convert.ToHook(ctx.Repo.RepoLink, hooks[i])
apiHooks[i], err = webhook_service.ToHook(ctx.Repo.RepoLink, hooks[i])
if err != nil {
ctx.InternalServerError(err)
return
@ -115,7 +116,7 @@ func GetHook(ctx *context.APIContext) {
if err != nil {
return
}
apiHook, err := convert.ToHook(repo.RepoLink, hook)
apiHook, err := webhook_service.ToHook(repo.RepoLink, hook)
if err != nil {
ctx.InternalServerError(err)
return
@ -176,7 +177,7 @@ func TestHook(ctx *context.APIContext) {
commit := convert.ToPayloadCommit(ctx.Repo.Repository, ctx.Repo.Commit)
commitID := ctx.Repo.Commit.ID.String()
if err := webhook_service.PrepareWebhook(ctx, hook, webhook.HookEventPush, &api.PushPayload{
if err := webhook_service.PrepareWebhook(ctx, hook, webhook_module.HookEventPush, &api.PushPayload{
Ref: ref,
Before: commitID,
After: commitID,