summaryrefslogtreecommitdiffstats
path: root/gateway/gateway.go
diff options
context:
space:
mode:
authorPatrick Connolly <patrick.c.connolly@gmail.com>2018-12-01 06:53:00 +0800
committerWim <wim@42.be>2018-11-30 23:53:00 +0100
commitf2088a687edd53e9e797f3b8941210ca3650cc45 (patch)
tree7a2adb7522e9696873fd734e4abb255759ba3b5e /gateway/gateway.go
parentfaeeee29482ffd23d26398bcaddea8dc885bc468 (diff)
downloadmatterbridge-msglm-f2088a687edd53e9e797f3b8941210ca3650cc45.tar.gz
matterbridge-msglm-f2088a687edd53e9e797f3b8941210ca3650cc45.tar.bz2
matterbridge-msglm-f2088a687edd53e9e797f3b8941210ca3650cc45.zip
Extract bridgeMap into own package to improve testability (#601)
Diffstat (limited to 'gateway/gateway.go')
-rw-r--r--gateway/gateway.go32
1 files changed, 1 insertions, 31 deletions
diff --git a/gateway/gateway.go b/gateway/gateway.go
index 2b8bdfa9..674179fb 100644
--- a/gateway/gateway.go
+++ b/gateway/gateway.go
@@ -13,20 +13,7 @@ import (
"time"
"github.com/42wim/matterbridge/bridge"
- "github.com/42wim/matterbridge/bridge/api"
"github.com/42wim/matterbridge/bridge/config"
- bdiscord "github.com/42wim/matterbridge/bridge/discord"
- bgitter "github.com/42wim/matterbridge/bridge/gitter"
- birc "github.com/42wim/matterbridge/bridge/irc"
- bmatrix "github.com/42wim/matterbridge/bridge/matrix"
- bmattermost "github.com/42wim/matterbridge/bridge/mattermost"
- brocketchat "github.com/42wim/matterbridge/bridge/rocketchat"
- bslack "github.com/42wim/matterbridge/bridge/slack"
- bsshchat "github.com/42wim/matterbridge/bridge/sshchat"
- bsteam "github.com/42wim/matterbridge/bridge/steam"
- btelegram "github.com/42wim/matterbridge/bridge/telegram"
- bxmpp "github.com/42wim/matterbridge/bridge/xmpp"
- bzulip "github.com/42wim/matterbridge/bridge/zulip"
"github.com/hashicorp/golang-lru"
"github.com/peterhellberg/emojilib"
log "github.com/sirupsen/logrus"
@@ -53,23 +40,6 @@ type BrMsgID struct {
var flog *log.Entry
-var bridgeMap = map[string]bridge.Factory{
- "api": api.New,
- "discord": bdiscord.New,
- "gitter": bgitter.New,
- "irc": birc.New,
- "mattermost": bmattermost.New,
- "matrix": bmatrix.New,
- "rocketchat": brocketchat.New,
- "slack-legacy": bslack.NewLegacy,
- "slack": bslack.New,
- "sshchat": bsshchat.New,
- "steam": bsteam.New,
- "telegram": btelegram.New,
- "xmpp": bxmpp.New,
- "zulip": bzulip.New,
-}
-
const (
apiProtocol = "api"
)
@@ -114,7 +84,7 @@ func (gw *Gateway) AddBridge(cfg *config.Bridge) error {
br.Log = log.WithFields(log.Fields{"prefix": "bridge"})
brconfig := &bridge.Config{Remote: gw.Message, Log: log.WithFields(log.Fields{"prefix": br.Protocol}), Bridge: br}
// add the actual bridger for this protocol to this bridge using the bridgeMap
- br.Bridger = bridgeMap[br.Protocol](brconfig)
+ br.Bridger = gw.Router.BridgeMap[br.Protocol](brconfig)
}
gw.mapChannelsToBridge(br)
gw.Bridges[cfg.Account] = br