diff options
| author | Shulhan <ms@kilabit.info> | 2026-01-21 01:12:11 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2026-01-21 01:12:11 +0700 |
| commit | fa4cc3a2ae6fa63bfbd8b005e4048dacc222dcc1 (patch) | |
| tree | b5566fe088dc51364101ab1db2a48ed845a4d832 /notif_config.go | |
| parent | d0969869954c299c04ea58ab0fda1eba6a0350da (diff) | |
| download | lilin-fa4cc3a2ae6fa63bfbd8b005e4048dacc222dcc1.tar.xz | |
all: implement default down and up templates under section "[default"]
To minimize defining the same templates in notification, user can set
default down and up templates under the default section.
Diffstat (limited to 'notif_config.go')
| -rw-r--r-- | notif_config.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/notif_config.go b/notif_config.go index c3ed43c..ca1a66b 100644 --- a/notif_config.go +++ b/notif_config.go @@ -43,7 +43,7 @@ type NotifConfig struct { Recipient []string `ini:"notif::recipient"` } -func (notifConfig *NotifConfig) init() (err error) { +func (notifConfig *NotifConfig) init(cfg *ServerConfig) (err error) { var logp = `notifConfig.init` switch notifConfig.Kind { @@ -66,7 +66,9 @@ func (notifConfig *NotifConfig) init() (err error) { default: return fmt.Errorf(`%s: unknown notif kind %q`, logp, notifConfig.Kind) } - if notifConfig.DownTemplate != "" { + if notifConfig.DownTemplate == `` { + notifConfig.downTmpl = cfg.downTmpl + } else { notifConfig.downTmpl = template.New(`down`) notifConfig.downTmpl, err = notifConfig.downTmpl.Parse(notifConfig.DownTemplate) if err != nil { @@ -74,7 +76,9 @@ func (notifConfig *NotifConfig) init() (err error) { logp, notifConfig.Kind, err) } } - if notifConfig.UpTemplate != "" { + if notifConfig.UpTemplate == `` { + notifConfig.upTmpl = cfg.upTmpl + } else { notifConfig.upTmpl = template.New(`up`) notifConfig.upTmpl, err = notifConfig.upTmpl.Parse(notifConfig.UpTemplate) if err != nil { |
