diff options
author | Wim <wim@42.be> | 2016-10-23 22:23:20 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2016-10-23 22:23:20 +0200 |
commit | e93847a95ed984837128b468cc3ab16702843095 (patch) | |
tree | 153b1d9d0f80029a565739dc333aa64ea9d77816 | |
parent | 545377742c268f1193246a4005c07b0d7a516eaa (diff) | |
download | matterbridge-msglm-e93847a95ed984837128b468cc3ab16702843095.tar.gz matterbridge-msglm-e93847a95ed984837128b468cc3ab16702843095.tar.bz2 matterbridge-msglm-e93847a95ed984837128b468cc3ab16702843095.zip |
Launch every account only once. Fixes #48
-rw-r--r-- | bridge/mattermost/mattermost.go | 5 | ||||
-rw-r--r-- | gateway/gateway.go | 9 |
2 files changed, 6 insertions, 8 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 2a9749d2..685d2929 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -106,10 +106,7 @@ func (b *Bmattermost) Protocol() string { func (b *Bmattermost) Send(msg config.Message) error { flog.Debugf("Receiving %#v", msg) - if msg.FullOrigin != b.FullOrigin() { - return b.SendType(msg.Username, msg.Text, msg.Channel, "") - } - return nil + return b.SendType(msg.Username, msg.Text, msg.Channel, "") } func (b *Bmattermost) SendType(nick string, message string, channel string, mtype string) error { diff --git a/gateway/gateway.go b/gateway/gateway.go index 45bb9e34..464a4d95 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -26,12 +26,12 @@ func New(cfg *config.Config, gateway *config.Gateway) error { gw.MyConfig = gateway exists := make(map[string]bool) for _, br := range append(gateway.In, gateway.Out...) { - if exists[br.Account+br.Channel] { + if exists[br.Account] { continue } log.Infof("Starting bridge: %s channel: %s", br.Account, br.Channel) gw.Bridges = append(gw.Bridges, bridge.New(cfg, &br, c)) - exists[br.Account+br.Channel] = true + exists[br.Account] = true } gw.mapChannels() gw.mapIgnores() @@ -103,10 +103,11 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) { if gw.ignoreMessage(&msg) { return } + originchannel := msg.Channel channels := gw.getDestChannel(&msg, dest.FullOrigin()) for _, channel := range channels { // do not send the message to the bridge we come from if also the channel is the same - if msg.FullOrigin == dest.FullOrigin() && msg.Channel == channel { + if msg.FullOrigin == dest.FullOrigin() && channel == originchannel { continue } msg.Channel = channel @@ -115,7 +116,7 @@ func (gw *Gateway) handleMessage(msg config.Message, dest bridge.Bridge) { 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, originchannel, dest.FullOrigin(), channel) err := dest.Send(msg) if err != nil { fmt.Println(err) |