diff options
author | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-04-05 21:23:54 +0200 |
---|---|---|
committer | Earl Warren <earl-warren@noreply.codeberg.org> | 2024-04-05 21:23:54 +0200 |
commit | 8205ed9495ddf57c0da36c365ce98adc879a4fc7 (patch) | |
tree | 725d42d4e65caac9d3c170855d7c1bc3d0c45ebb /routers | |
parent | Merge pull request 'Update dependency @stoplight/spectral-cli to v6.11.1' (#3... (diff) | |
parent | [FEAT] sourcehut webhooks (diff) | |
download | forgejo-8205ed9495ddf57c0da36c365ce98adc879a4fc7.tar.xz forgejo-8205ed9495ddf57c0da36c365ce98adc879a4fc7.zip |
Merge pull request '[FEAT] sourcehut webhooks' (#3022) from oliverpool/forgejo:webhook_7_sourcehut into forgejo
Reviewed-on: https://codeberg.org/forgejo/forgejo/pulls/3022
Reviewed-by: Earl Warren <earl-warren@noreply.codeberg.org>
Reviewed-by: 0ko <0ko@noreply.codeberg.org>
Diffstat (limited to 'routers')
-rw-r--r-- | routers/web/repo/setting/webhook.go | 24 |
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 |