mirror of
https://github.com/yusing/godoxy.git
synced 2026-04-21 16:01:22 +02:00
[BREAKING] changed notification config format, support multiple notification providers, support webhook and markdown style notification
This commit is contained in:
@@ -187,14 +187,17 @@ func (cfg *Config) load() E.Error {
|
||||
return errs.Error()
|
||||
}
|
||||
|
||||
func (cfg *Config) initNotification(notifCfgMap types.NotificationConfigMap) (err E.Error) {
|
||||
if len(notifCfgMap) == 0 {
|
||||
func (cfg *Config) initNotification(notifCfg []types.NotificationConfig) (err E.Error) {
|
||||
if len(notifCfg) == 0 {
|
||||
return
|
||||
}
|
||||
errs := E.NewBuilder("notification providers load errors")
|
||||
for name, notifCfg := range notifCfgMap {
|
||||
_, err := notif.RegisterProvider(cfg.task.Subtask(name), notifCfg)
|
||||
errs.Add(err)
|
||||
for i, notifier := range notifCfg {
|
||||
_, err := notif.RegisterProvider(cfg.task.Subtask("notifier"), notifier)
|
||||
if err == nil {
|
||||
continue
|
||||
}
|
||||
errs.Add(err.Subjectf("[%d]", i))
|
||||
}
|
||||
return errs.Error()
|
||||
}
|
||||
|
||||
@@ -11,10 +11,11 @@ type (
|
||||
RedirectToHTTPS bool `json:"redirect_to_https" yaml:"redirect_to_https"`
|
||||
}
|
||||
Providers struct {
|
||||
Files []string `json:"include" yaml:"include"`
|
||||
Docker map[string]string `json:"docker" yaml:"docker"`
|
||||
Notification NotificationConfigMap `json:"notification" yaml:"notification"`
|
||||
Files []string `json:"include" yaml:"include"`
|
||||
Docker map[string]string `json:"docker" yaml:"docker"`
|
||||
Notification []NotificationConfig `json:"notification" yaml:"notification"`
|
||||
}
|
||||
NotificationConfig map[string]any
|
||||
)
|
||||
|
||||
func DefaultConfig() *Config {
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package types
|
||||
|
||||
import "github.com/yusing/go-proxy/internal/notif"
|
||||
|
||||
type NotificationConfigMap map[string]notif.ProviderConfig
|
||||
Reference in New Issue
Block a user