github.com/gitbundle/modules@v0.0.0-20231025071548-85b91c5c3b01/setting/webhook.go (about) 1 // Copyright 2023 The GitBundle Inc. All rights reserved. 2 // Copyright 2017 The Gitea Authors. All rights reserved. 3 // Use of this source code is governed by a MIT-style 4 // license that can be found in the LICENSE file. 5 6 package setting 7 8 import ( 9 "net/url" 10 11 "github.com/gitbundle/modules/log" 12 ) 13 14 // Webhook settings 15 var Webhook = struct { 16 QueueLength int 17 DeliverTimeout int 18 SkipTLSVerify bool 19 AllowedHostList string 20 Types []string 21 PagingNum int 22 ProxyURL string 23 ProxyURLFixed *url.URL 24 ProxyHosts []string 25 }{ 26 QueueLength: 1000, 27 DeliverTimeout: 5, 28 SkipTLSVerify: false, 29 PagingNum: 10, 30 ProxyURL: "", 31 ProxyHosts: []string{}, 32 } 33 34 func newWebhookService() { 35 sec := Cfg.Section("webhook") 36 Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000) 37 Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) 38 Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() 39 Webhook.AllowedHostList = sec.Key("ALLOWED_HOST_LIST").MustString("") 40 Webhook.Types = []string{"gitbundle", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork", "packagist"} 41 Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10) 42 Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("") 43 if Webhook.ProxyURL != "" { 44 var err error 45 Webhook.ProxyURLFixed, err = url.Parse(Webhook.ProxyURL) 46 if err != nil { 47 log.Error("Webhook PROXY_URL is not valid") 48 Webhook.ProxyURL = "" 49 } 50 } 51 Webhook.ProxyHosts = sec.Key("PROXY_HOSTS").Strings(",") 52 }