summaryrefslogtreecommitdiffstats
path: root/gateway/samechannel/samechannel.go
blob: 1d85ea7d5191deb0ec2e1118b98b1dd9df9143ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
package samechannelgateway

import (
	"github.com/42wim/matterbridge/bridge/config"
)

type SameChannelGateway struct {
	config.Config
}

func New(cfg config.Config) *SameChannelGateway {
	return &SameChannelGateway{Config: cfg}
}

func (sgw *SameChannelGateway) GetConfig() []config.Gateway {
	var gwconfigs []config.Gateway
	cfg := sgw.Config
	for _, gw := range cfg.BridgeValues().SameChannelGateway {
		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})
			}
		}
		gwconfigs = append(gwconfigs, gwconfig)
	}
	return gwconfigs
}