From 3a9bcdb3061675183db8916c78332be2ad9c6f95 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 9 Mar 2024 18:00:41 +0800 Subject: [PATCH 1/3] Fix wechatwork webhook --- routers/web/repo/setting/webhook.go | 1 + 1 file changed, 1 insertion(+) diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index bba4d4df51e41..db0e3d7ab5de0 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -551,6 +551,7 @@ func wechatworkHookParams(ctx *context.Context) webhookParams { Type: webhook_module.WECHATWORK, URL: form.PayloadURL, ContentType: webhook.ContentTypeJSON, + HTTPMethod: http.MethodPost, WebhookForm: form.WebhookForm, } } From 6052ecf14fb2258e267ca87a31a6e58ae7571158 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sat, 9 Mar 2024 22:36:45 +0800 Subject: [PATCH 2/3] Use post method as default --- services/webhook/payloader.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/services/webhook/payloader.go b/services/webhook/payloader.go index abf9946cca47f..54a11a58682d2 100644 --- a/services/webhook/payloader.go +++ b/services/webhook/payloader.go @@ -94,7 +94,12 @@ func newJSONRequest[T any](pc payloadConvertor[T], w *webhook_model.Webhook, t * return nil, nil, err } - req, err := http.NewRequest(w.HTTPMethod, w.URL, bytes.NewReader(body)) + method := w.HTTPMethod + if method == "" { + method = http.MethodPost + } + + req, err := http.NewRequest(method, w.URL, bytes.NewReader(body)) if err != nil { return nil, nil, err } From 31035c585d274cbbaa30756ed2ec5a8c40cac5fc Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Sun, 10 Mar 2024 00:37:31 +0800 Subject: [PATCH 3/3] Revert unnecessary change --- routers/web/repo/setting/webhook.go | 1 - 1 file changed, 1 deletion(-) diff --git a/routers/web/repo/setting/webhook.go b/routers/web/repo/setting/webhook.go index db0e3d7ab5de0..bba4d4df51e41 100644 --- a/routers/web/repo/setting/webhook.go +++ b/routers/web/repo/setting/webhook.go @@ -551,7 +551,6 @@ func wechatworkHookParams(ctx *context.Context) webhookParams { Type: webhook_module.WECHATWORK, URL: form.PayloadURL, ContentType: webhook.ContentTypeJSON, - HTTPMethod: http.MethodPost, WebhookForm: form.WebhookForm, } }