From 730ccdd4567de7bbcf8794fef95a7324cef5198b Mon Sep 17 00:00:00 2001 From: Wim <wim@42.be> Date: Sun, 11 Nov 2018 21:56:12 +0100 Subject: [PATCH] Add support for mattermost matterbridge plugin --- gateway/gateway.go | 6 ++++++ gateway/router.go | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/gateway/gateway.go b/gateway/gateway.go index 442e27fb..728ed703 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -321,6 +321,12 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM msg.ParentID = canonicalParentMsgID } + // if we are using mattermost plugin account, send messages to MattermostPlugin channel + // that can be picked up by the mattermost matterbridge plugin + if dest.Account == "mattermost.plugin" { + gw.Router.MattermostPlugin <- msg + } + mID, err := dest.Send(msg) if err != nil { flog.Error(err) diff --git a/gateway/router.go b/gateway/router.go index 1ea3f940..030b7b1e 100644 --- a/gateway/router.go +++ b/gateway/router.go @@ -11,13 +11,14 @@ import ( ) type Router struct { - Gateways map[string]*Gateway - Message chan config.Message + Gateways map[string]*Gateway + Message chan config.Message + MattermostPlugin chan config.Message *config.Config } func NewRouter(cfg *config.Config) (*Router, error) { - r := &Router{Message: make(chan config.Message), Gateways: make(map[string]*Gateway), Config: cfg} + r := &Router{Message: make(chan config.Message), MattermostPlugin: make(chan config.Message), Gateways: make(map[string]*Gateway), Config: cfg} sgw := samechannelgateway.New(cfg) gwconfigs := sgw.GetConfig()