From 9d04ff6a4d1dde541a0253e0db59957c69fec4cf Mon Sep 17 00:00:00 2001 From: cel 🌸 Date: Tue, 10 Sep 2024 17:33:54 +0100 Subject: WIP: genericize notifier as interface --- config/config.go | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'config') diff --git a/config/config.go b/config/config.go index 52ed1db..139687d 100644 --- a/config/config.go +++ b/config/config.go @@ -10,7 +10,7 @@ import ( type Config struct { Name string `mapstructure:"name" yaml:"name"` - Telegram TelegramConfig `mapstructure:"telegram" yaml:"telegram"` + Notifiers NotifiersConfig `mapstructure:"notifiers" yaml:"notifiers"` Database DatabaseConfig `mapstructure:"database" yaml:"database"` Jwt JwtConfig `mapstructure:"jwt" yaml:"jwt"` Server ServerConfig `mapstructure:"server" yaml:"server"` @@ -20,6 +20,10 @@ type Config struct { IsDoneTickDotCom bool `mapstructure:"is_done_tick_dot_com" yaml:"is_done_tick_dot_com"` } +type NotifiersConfig struct { + Telegram TelegramConfig `mapstructure:"telegram" yaml:"telegram"` +} + type TelegramConfig struct { Token string `mapstructure:"token" yaml:"token"` } @@ -80,9 +84,6 @@ type EmailConfig struct { func NewConfig() *Config { return &Config{ - Telegram: TelegramConfig{ - Token: "", - }, Database: DatabaseConfig{ Type: "sqlite", Migration: true, @@ -96,7 +97,7 @@ func NewConfig() *Config { } func configEnvironmentOverrides(Config *Config) { if os.Getenv("DONETICK_TELEGRAM_TOKEN") != "" { - Config.Telegram.Token = os.Getenv("DONETICK_TELEGRAM_TOKEN") + Config.Notifiers.Telegram.Token = os.Getenv("DONETICK_TELEGRAM_TOKEN") } } func LoadConfig() *Config { -- cgit