diff options
author | oliverpool <git@olivier.pfad.fr> | 2024-03-21 13:42:40 +0100 |
---|---|---|
committer | oliverpool <git@olivier.pfad.fr> | 2024-03-27 15:38:38 +0100 |
commit | 7e0965b02c8cf9ecb14cdaeaeec7b1612010a603 (patch) | |
tree | 494cdba229254325d4f59fdcb9851bb601891b43 /routers/web/repo/setting/webhook.go | |
parent | [REFACTOR] webhook matrix endpoints (diff) | |
download | forgejo-7e0965b02c8cf9ecb14cdaeaeec7b1612010a603.tar.xz forgejo-7e0965b02c8cf9ecb14cdaeaeec7b1612010a603.zip |
[REFACTOR] webhook forgejo/gitea endpoints
Diffstat (limited to 'routers/web/repo/setting/webhook.go')
-rw-r--r-- | routers/web/repo/setting/webhook.go | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index f41752e470..8900942190 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -361,62 +361,6 @@ func editWebhook(ctx *context.Context, params webhookParams) { ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID)) } -// ForgejoHooksNewPost response for creating Forgejo webhook -func ForgejoHooksNewPost(ctx *context.Context) { - createWebhook(ctx, forgejoHookParams(ctx)) -} - -// ForgejoHooksEditPost response for editing Forgejo webhook -func ForgejoHooksEditPost(ctx *context.Context) { - editWebhook(ctx, forgejoHookParams(ctx)) -} - -func forgejoHookParams(ctx *context.Context) webhookParams { - form := web.GetForm(ctx).(*forms.NewWebhookForm) - - contentType := webhook.ContentTypeJSON - if webhook.HookContentType(form.ContentType) == webhook.ContentTypeForm { - contentType = webhook.ContentTypeForm - } - - return webhookParams{ - Type: webhook_module.FORGEJO, - URL: form.PayloadURL, - ContentType: contentType, - Secret: form.Secret, - HTTPMethod: form.HTTPMethod, - WebhookForm: form.WebhookForm, - } -} - -// GiteaHooksNewPost response for creating Gitea webhook -func GiteaHooksNewPost(ctx *context.Context) { - createWebhook(ctx, giteaHookParams(ctx)) -} - -// GiteaHooksEditPost response for editing Gitea webhook -func GiteaHooksEditPost(ctx *context.Context) { - editWebhook(ctx, giteaHookParams(ctx)) -} - -func giteaHookParams(ctx *context.Context) webhookParams { - form := web.GetForm(ctx).(*forms.NewWebhookForm) - - contentType := webhook.ContentTypeJSON - if webhook.HookContentType(form.ContentType) == webhook.ContentTypeForm { - contentType = webhook.ContentTypeForm - } - - return webhookParams{ - Type: webhook_module.GITEA, - URL: form.PayloadURL, - ContentType: contentType, - Secret: form.Secret, - HTTPMethod: form.HTTPMethod, - WebhookForm: form.WebhookForm, - } -} - // GogsHooksNewPost response for creating Gogs webhook func GogsHooksNewPost(ctx *context.Context) { createWebhook(ctx, gogsHookParams(ctx)) |