From b38360c9a59624866e467de81acf62e38af8db59 Mon Sep 17 00:00:00 2001 From: kolaente Date: Tue, 17 Oct 2023 19:06:25 +0200 Subject: [PATCH] feat(webhooks): add timeout config option --- pkg/config/config.go | 1 + pkg/models/webhooks.go | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index c1fbaa74eac..0b39a318d09 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -392,6 +392,7 @@ func InitDefaultConfig() { DefaultSettingsOverdueTaskRemindersTime.setDefault("9:00") // Webhook WebhooksEnabled.setDefault(true) + WebhooksTimeoutSeconds.setDefault(30) } // InitConfig initializes the config, sets defaults etc. diff --git a/pkg/models/webhooks.go b/pkg/models/webhooks.go index f440d8f2ea3..4f32a84cafe 100644 --- a/pkg/models/webhooks.go +++ b/pkg/models/webhooks.go @@ -162,7 +162,10 @@ func (w *Webhook) sendWebhookPayload(p *WebhookPayload) (err error) { req.Header.Add("User-Agent", "Vikunja/"+version.Version) - _, err = http.DefaultClient.Do(req) + client := http.DefaultClient + client.Timeout = time.Duration(config.WebhooksTimeoutSeconds.GetInt()) * time.Second + + _, err = client.Do(req) if err == nil { log.Debugf("Sent webhook payload for webhook %d for event %s", w.ID, p.EventName) }