feat(webhooks): add timeout config option

This commit is contained in:
kolaente 2023-10-17 19:06:25 +02:00
parent 34a92b759e
commit b38360c9a5
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
2 changed files with 5 additions and 1 deletions

View File

@ -392,6 +392,7 @@ func InitDefaultConfig() {
DefaultSettingsOverdueTaskRemindersTime.setDefault("9:00")
// Webhook
WebhooksEnabled.setDefault(true)
WebhooksTimeoutSeconds.setDefault(30)
}
// InitConfig initializes the config, sets defaults etc.

View File

@ -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)
}