4
0
mirror of https://github.com/cwinfo/matterbridge.git synced 2025-06-27 04:09:24 +00:00

Add sane RemoteNickFormat default for API (#1157)

This commit is contained in:
Qais Patankar
2020-06-24 23:25:10 +01:00
committed by GitHub
parent 37f7caf7f3
commit a41accd033
3 changed files with 33 additions and 6 deletions

View File

@ -219,6 +219,7 @@ type BridgeValues struct {
type Config interface {
Viper() *viper.Viper
BridgeValues() *BridgeValues
IsKeySet(key string) bool
GetBool(key string) (bool, bool)
GetInt(key string) (int, bool)
GetString(key string) (string, bool)
@ -303,6 +304,12 @@ func (c *config) Viper() *viper.Viper {
return c.v
}
func (c *config) IsKeySet(key string) bool {
c.RLock()
defer c.RUnlock()
return c.v.IsSet(key)
}
func (c *config) GetBool(key string) (bool, bool) {
c.RLock()
defer c.RUnlock()
@ -362,6 +369,11 @@ type TestConfig struct {
Overrides map[string]interface{}
}
func (c *TestConfig) IsKeySet(key string) bool {
_, ok := c.Overrides[key]
return ok || c.Config.IsKeySet(key)
}
func (c *TestConfig) GetBool(key string) (bool, bool) {
val, ok := c.Overrides[key]
if ok {