diff options
author | Wim <wim@42.be> | 2018-01-21 12:21:55 +0100 |
---|---|---|
committer | Wim <wim@42.be> | 2018-01-21 12:21:55 +0100 |
commit | 6523494e83a97ccddfa5993d979bbac470fb09c5 (patch) | |
tree | c8c7c4c5a9a6ae3a90d07c6f57d651ea9bbba5e2 /gateway/gateway.go | |
parent | 7c6ce8bb90982edf6e9f01a8aed310c257048fec (diff) | |
download | matterbridge-msglm-6523494e83a97ccddfa5993d979bbac470fb09c5.tar.gz matterbridge-msglm-6523494e83a97ccddfa5993d979bbac470fb09c5.tar.bz2 matterbridge-msglm-6523494e83a97ccddfa5993d979bbac470fb09c5.zip |
Obey the Gateway value from the json (api). Closes #344
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r-- | gateway/gateway.go | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go index 89ea80ab..a316c34d 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -119,6 +119,12 @@ func (gw *Gateway) mapChannels() error { func (gw *Gateway) getDestChannel(msg *config.Message, dest bridge.Bridge) []config.ChannelInfo { var channels []config.ChannelInfo + + // for messages received from the api check that the gateway is the specified one + if msg.Protocol == "api" && gw.Name != msg.Gateway { + return channels + } + // if source channel is in only, do nothing for _, channel := range gw.Channels { // lookup the channel from the message @@ -321,7 +327,11 @@ func (gw *Gateway) modifyMessage(msg *config.Message) { } msg.Text = re.ReplaceAllString(msg.Text, replace) } - msg.Gateway = gw.Name + + // messages from api have Gateway specified, don't overwrite + if msg.Protocol != "api" { + msg.Gateway = gw.Name + } } func (gw *Gateway) handleFiles(msg *config.Message) { |