From 60aca9ea18f4fed6c98c83d41036f9a34fdbd28c Mon Sep 17 00:00:00 2001 From: Unknwon Date: Tue, 21 Feb 2017 20:21:25 -0500 Subject: webhook: also only enable certain types (#3356) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add new config option '[webhook] TYPES’. --- modules/setting/setting.go | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'modules/setting') diff --git a/modules/setting/setting.go b/modules/setting/setting.go index f0960aef..7652e0eb 100644 --- a/modules/setting/setting.go +++ b/modules/setting/setting.go @@ -107,15 +107,6 @@ var ( UsePostgreSQL bool UseMSSQL bool - // Webhook settings - Webhook struct { - QueueLength int - DeliverTimeout int - SkipTLSVerify bool - Types []string - PagingNum int - } - // Repository settings Repository struct { AnsiCharset string @@ -146,6 +137,15 @@ var ( RepoRootPath string ScriptType string + // Webhook settings + Webhook struct { + Types []string + QueueLength int + DeliverTimeout int + SkipTLSVerify bool + PagingNum int + } + // Markdown sttings Markdown struct { EnableHardLineBreak bool @@ -579,6 +579,8 @@ func NewContext() { if err = Cfg.Section("http").MapTo(&HTTP); err != nil { log.Fatal(2, "Fail to map HTTP settings: %v", err) + } else if err = Cfg.Section("webhook").MapTo(&Webhook); err != nil { + log.Fatal(2, "Fail to map Webhook settings: %v", err) } else if err = Cfg.Section("markdown").MapTo(&Markdown); err != nil { log.Fatal(2, "Fail to map Markdown settings: %v", err) } else if err = Cfg.Section("admin").MapTo(&Admin); err != nil { @@ -822,15 +824,6 @@ func newNotifyMailService() { log.Info("Notify Mail Service Enabled") } -func newWebhookService() { - sec := Cfg.Section("webhook") - Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000) - Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) - Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() - Webhook.Types = []string{"gogs", "slack", "discord"} - Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10) -} - func NewService() { newService() } @@ -843,5 +836,4 @@ func NewServices() { newMailService() newRegisterMailService() newNotifyMailService() - newWebhookService() } -- cgit v1.2.3