2019-02-23 22:51:27 +01:00
|
|
|
package samechannel
|
2016-09-30 23:19:47 +02:00
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/42wim/matterbridge/bridge/config"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SameChannelGateway struct {
|
2018-11-13 23:30:56 +01:00
|
|
|
config.Config
|
2016-09-30 23:19:47 +02:00
|
|
|
}
|
|
|
|
|
2018-11-13 23:30:56 +01:00
|
|
|
func New(cfg config.Config) *SameChannelGateway {
|
2017-04-01 17:24:19 +02:00
|
|
|
return &SameChannelGateway{Config: cfg}
|
2016-09-30 23:19:47 +02:00
|
|
|
}
|
|
|
|
|
2017-04-01 17:24:19 +02:00
|
|
|
func (sgw *SameChannelGateway) GetConfig() []config.Gateway {
|
|
|
|
var gwconfigs []config.Gateway
|
|
|
|
cfg := sgw.Config
|
2018-11-15 20:43:43 +01:00
|
|
|
for _, gw := range cfg.BridgeValues().SameChannelGateway {
|
2017-04-01 17:24:19 +02:00
|
|
|
gwconfig := config.Gateway{Name: gw.Name, Enable: gw.Enable}
|
|
|
|
for _, account := range gw.Accounts {
|
|
|
|
for _, channel := range gw.Channels {
|
|
|
|
gwconfig.InOut = append(gwconfig.InOut, config.Bridge{Account: account, Channel: channel, SameChannel: true})
|
|
|
|
}
|
2016-09-30 23:19:47 +02:00
|
|
|
}
|
2017-04-01 17:24:19 +02:00
|
|
|
gwconfigs = append(gwconfigs, gwconfig)
|
2016-09-30 23:19:47 +02:00
|
|
|
}
|
2017-04-01 17:24:19 +02:00
|
|
|
return gwconfigs
|
2016-11-11 15:23:22 +01:00
|
|
|
}
|