From 6523494e83a97ccddfa5993d979bbac470fb09c5 Mon Sep 17 00:00:00 2001 From: Wim Date: Sun, 21 Jan 2018 12:21:55 +0100 Subject: [PATCH] Obey the Gateway value from the json (api). Closes #344 --- gateway/gateway.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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) {