summaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authoroliverpool <git@olivier.pfad.fr>2024-04-03 14:22:36 +0200
committeroliverpool <git@olivier.pfad.fr>2024-04-04 08:24:33 +0200
commit04a398a1af8ab7552f89da4cfb9d34b9698e341c (patch)
tree90d0b2e3e35ae99a49a38f02ab3bce4fe29f76d2 /routers
parentMerge pull request 'Update dependency go to v1.22.2' (#3015) from renovate/go... (diff)
downloadforgejo-04a398a1af8ab7552f89da4cfb9d34b9698e341c.tar.xz
forgejo-04a398a1af8ab7552f89da4cfb9d34b9698e341c.zip
[REFACTOR] webhook shared code to prevent import cycles
Diffstat (limited to 'routers')
-rw-r--r--routers/web/repo/setting/webhook.go24
1 files changed, 12 insertions, 12 deletions
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go
index 4469eac9e8..eee493e2c2 100644
--- a/routers/web/repo/setting/webhook.go
+++ b/routers/web/repo/setting/webhook.go
@@ -148,7 +148,7 @@ func WebhookNew(ctx *context.Context) {
}
// ParseHookEvent convert web form content to webhook.HookEvent
-func ParseHookEvent(form forms.WebhookForm) *webhook_module.HookEvent {
+func ParseHookEvent(form forms.WebhookCoreForm) *webhook_module.HookEvent {
return &webhook_module.HookEvent{
PushOnly: form.PushOnly(),
SendEverything: form.SendEverything(),
@@ -188,7 +188,7 @@ func WebhookCreate(ctx *context.Context) {
return
}
- fields := handler.FormFields(func(form any) {
+ fields := handler.UnmarshalForm(func(form any) {
errs := binding.Bind(ctx.Req, form)
middleware.Validate(errs, ctx.Data, form, ctx.Locale) // error checked below in ctx.HasError
})
@@ -215,10 +215,10 @@ func WebhookCreate(ctx *context.Context) {
w.URL = fields.URL
w.ContentType = fields.ContentType
w.Secret = fields.Secret
- w.HookEvent = ParseHookEvent(fields.WebhookForm)
- w.IsActive = fields.WebhookForm.Active
+ w.HookEvent = ParseHookEvent(fields.WebhookCoreForm)
+ w.IsActive = fields.Active
w.HTTPMethod = fields.HTTPMethod
- err := w.SetHeaderAuthorization(fields.WebhookForm.AuthorizationHeader)
+ err := w.SetHeaderAuthorization(fields.AuthorizationHeader)
if err != nil {
ctx.ServerError("SetHeaderAuthorization", err)
return
@@ -245,14 +245,14 @@ func WebhookCreate(ctx *context.Context) {
HTTPMethod: fields.HTTPMethod,
ContentType: fields.ContentType,
Secret: fields.Secret,
- HookEvent: ParseHookEvent(fields.WebhookForm),
- IsActive: fields.WebhookForm.Active,
+ HookEvent: ParseHookEvent(fields.WebhookCoreForm),
+ IsActive: fields.Active,
Type: hookType,
Meta: string(meta),
OwnerID: orCtx.OwnerID,
IsSystemWebhook: orCtx.IsSystemWebhook,
}
- err = w.SetHeaderAuthorization(fields.WebhookForm.AuthorizationHeader)
+ err = w.SetHeaderAuthorization(fields.AuthorizationHeader)
if err != nil {
ctx.ServerError("SetHeaderAuthorization", err)
return
@@ -286,7 +286,7 @@ func WebhookUpdate(ctx *context.Context) {
return
}
- fields := handler.FormFields(func(form any) {
+ fields := handler.UnmarshalForm(func(form any) {
errs := binding.Bind(ctx.Req, form)
middleware.Validate(errs, ctx.Data, form, ctx.Locale) // error checked below in ctx.HasError
})
@@ -295,11 +295,11 @@ func WebhookUpdate(ctx *context.Context) {
w.URL = fields.URL
w.ContentType = fields.ContentType
w.Secret = fields.Secret
- w.HookEvent = ParseHookEvent(fields.WebhookForm)
- w.IsActive = fields.WebhookForm.Active
+ w.HookEvent = ParseHookEvent(fields.WebhookCoreForm)
+ w.IsActive = fields.Active
w.HTTPMethod = fields.HTTPMethod
- err := w.SetHeaderAuthorization(fields.WebhookForm.AuthorizationHeader)
+ err := w.SetHeaderAuthorization(fields.AuthorizationHeader)
if err != nil {
ctx.ServerError("SetHeaderAuthorization", err)
return