diff options
author | Wim <wim@42.be> | 2017-02-14 23:52:45 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2017-02-14 23:52:45 +0100 |
commit | dc3723210076d7f7fecdfbf98b5de2f4540900ea (patch) | |
tree | 4ea4e6f055562d3f884f2c1b5c65bcbf79f5844c /gateway | |
parent | 163f55f9c27e9e8a75774424d22598799e8306c6 (diff) | |
download | matterbridge-msglm-dc3723210076d7f7fecdfbf98b5de2f4540900ea.tar.gz matterbridge-msglm-dc3723210076d7f7fecdfbf98b5de2f4540900ea.tar.bz2 matterbridge-msglm-dc3723210076d7f7fecdfbf98b5de2f4540900ea.zip |
Refactor. Make extra options easier for other protocols
Diffstat (limited to 'gateway')
-rw-r--r-- | gateway/gateway.go | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go index 19571776..95bf902a 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -40,10 +40,8 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { } log.Infof("Starting bridge: %s ", cfg.Account) br := bridge.New(gw.Config, cfg, gw.Message) - br.ChannelsOut = gw.ChannelsOut[br.Account] - br.ChannelsIn = gw.ChannelsIn[br.Account] - br.ChannelOptions = gw.ChannelOptions[br.Account] - + gw.mapChannelsToBridge(br, gw.ChannelsOut) + gw.mapChannelsToBridge(br, gw.ChannelsIn) gw.Bridges[cfg.Account] = br err := br.Connect() if err != nil { @@ -53,6 +51,16 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error { return nil } +func (gw *Gateway) mapChannelsToBridge(br *bridge.Bridge, cMap map[string][]string) { + for _, channel := range cMap[br.Account] { + if _, ok := gw.ChannelOptions[br.Account+channel]; ok { + br.ChannelsOut[channel] = gw.ChannelOptions[br.Account+channel] + } else { + br.ChannelsOut[channel] = config.ChannelOptions{} + } + } +} + func (gw *Gateway) Start() error { gw.mapChannels() for _, br := range append(gw.MyConfig.In, append(gw.MyConfig.InOut, gw.MyConfig.Out...)...) { |