mirror of
https://github.com/cwinfo/matterbridge.git
synced 2025-07-11 02:36:28 +00:00
Fail if: * we don't have any gateways configured * we have gateways configured but with non-existing bridge configuration * we have gateways configured without any configuration
This commit is contained in:
@ -85,6 +85,7 @@ func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string {
|
||||
func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
|
||||
br := gw.Router.getBridge(cfg.Account)
|
||||
if br == nil {
|
||||
gw.checkConfig(cfg)
|
||||
br = bridge.New(cfg)
|
||||
br.Config = gw.Router.Config
|
||||
br.General = &gw.BridgeValues().General
|
||||
@ -104,6 +105,19 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (gw *Gateway) checkConfig(cfg *config.Bridge) {
|
||||
match := false
|
||||
for _, key := range gw.Router.Config.Viper().AllKeys() {
|
||||
if strings.HasPrefix(key, cfg.Account) {
|
||||
match = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !match {
|
||||
gw.logger.Fatalf("Account %s defined in gateway %s but no configuration found, exiting.", cfg.Account, gw.Name)
|
||||
}
|
||||
}
|
||||
|
||||
// AddConfig associates a new configuration with the gateway object.
|
||||
func (gw *Gateway) AddConfig(cfg *config.Gateway) error {
|
||||
gw.Name = cfg.Name
|
||||
|
Reference in New Issue
Block a user