diff options
author | Wim <wim@42.be> | 2016-11-11 15:23:22 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2016-11-11 15:23:22 +0100 |
commit | 08ebee6b4faf677da159db1cffea292050492fd5 (patch) | |
tree | 130482bf07bef7400afd97288b9449b764c9b52d /gateway/samechannel/samechannel.go | |
parent | a3dd0f1345fae3d7828ed0c82d6a7c4b610d0983 (diff) | |
download | matterbridge-msglm-08ebee6b4faf677da159db1cffea292050492fd5.tar.gz matterbridge-msglm-08ebee6b4faf677da159db1cffea292050492fd5.tar.bz2 matterbridge-msglm-08ebee6b4faf677da159db1cffea292050492fd5.zip |
Validate channels for samechannelgateway. Fixes #73.
Diffstat (limited to 'gateway/samechannel/samechannel.go')
-rw-r--r-- | gateway/samechannel/samechannel.go | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/gateway/samechannel/samechannel.go b/gateway/samechannel/samechannel.go index 5cdd59ae..2240ee84 100644 --- a/gateway/samechannel/samechannel.go +++ b/gateway/samechannel/samechannel.go @@ -54,12 +54,16 @@ func (gw *SameChannelGateway) handleReceive(c chan config.Message) { } func (gw *SameChannelGateway) handleMessage(msg config.Message, dest bridge.Bridge) { + // is this a configured channel + if !gw.validChannel(msg.Channel) { + return + } // do not send the message to the bridge we come from if also the channel is the same if msg.FullOrigin == dest.FullOrigin() { return } gw.modifyMessage(&msg, dest) - log.Debugf("Sending %#v from %s to %s", msg, msg.FullOrigin, dest.FullOrigin()) + log.Debugf("Sending %#v from %s (%s) to %s (%s)", msg, msg.FullOrigin, msg.Channel, dest.FullOrigin(), msg.Channel) err := dest.Send(msg) if err != nil { log.Error(err) @@ -88,3 +92,12 @@ func (gw *SameChannelGateway) modifyMessage(msg *config.Message, dest bridge.Bri setNickFormat(msg, gw.Config.Discord[dest.Origin()].RemoteNickFormat) } } + +func (gw *SameChannelGateway) validChannel(channel string) bool { + for _, c := range gw.Channels { + if c == channel { + return true + } + } + return false +} |