diff options
author | Wim <wim@42.be> | 2017-06-24 19:36:10 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2017-06-29 23:38:48 +0200 |
commit | 830361e48bab699d7a22af1eba3f3df85ac21bd3 (patch) | |
tree | a5b3c02f33efb5ed5c629f923e104ad287bc5842 /bridge/mattermost | |
parent | 1b1a9ce2503021c275a470c8da21d33bbdcf5681 (diff) | |
download | matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.tar.gz matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.tar.bz2 matterbridge-msglm-830361e48bab699d7a22af1eba3f3df85ac21bd3.zip |
Deprecate URL,useAPI,BindAddress (slack,mattermost,rocketchat)v0.16.0-rc1
Diffstat (limited to 'bridge/mattermost')
-rw-r--r-- | bridge/mattermost/mattermost.go | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index e88bf838..222522ee 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -55,12 +55,18 @@ func (b *Bmattermost) Command(cmd string) string { } func (b *Bmattermost) Connect() error { - if !b.Config.UseAPI { - flog.Info("Connecting webhooks") - b.mh = matterhook.New(b.Config.URL, + if b.Config.WebhookURL != "" && b.Config.WebhookBindAddress != "" { + flog.Info("Connecting using webhookurl and webhookbindaddress") + b.mh = matterhook.New(b.Config.WebhookURL, matterhook.Config{InsecureSkipVerify: b.Config.SkipTLSVerify, - BindAddress: b.Config.BindAddress}) + BindAddress: b.Config.WebhookBindAddress}) + } else if b.Config.WebhookURL != "" { + flog.Info("Connecting using webhookurl (for posting) and token") + b.mh = matterhook.New(b.Config.WebhookURL, + matterhook.Config{InsecureSkipVerify: b.Config.SkipTLSVerify, + DisableServer: true}) } else { + flog.Info("Connecting using token") b.mc = matterclient.New(b.Config.Login, b.Config.Password, b.Config.Team, b.Config.Server) b.mc.SkipTLSVerify = b.Config.SkipTLSVerify @@ -85,7 +91,7 @@ func (b *Bmattermost) Disconnect() error { func (b *Bmattermost) JoinChannel(channel string) error { // we can only join channels using the API - if b.Config.UseAPI { + if b.Config.WebhookURL == "" && b.Config.WebhookBindAddress == "" { return b.mc.JoinChannel(b.mc.GetChannelId(channel, "")) } return nil @@ -100,7 +106,7 @@ func (b *Bmattermost) Send(msg config.Message) error { if b.Config.PrefixMessagesWithNick { message = nick + message } - if !b.Config.UseAPI { + if b.Config.WebhookURL != "" { matterMessage := matterhook.OMessage{IconURL: b.Config.IconURL} matterMessage.IconURL = msg.Avatar matterMessage.Channel = channel @@ -119,12 +125,13 @@ func (b *Bmattermost) Send(msg config.Message) error { } func (b *Bmattermost) handleMatter() { - flog.Debugf("Choosing API based Mattermost connection: %t", b.Config.UseAPI) mchan := make(chan *MMMessage) - if b.Config.UseAPI { - go b.handleMatterClient(mchan) - } else { + if b.Config.WebhookBindAddress != "" && b.Config.WebhookURL != "" { + flog.Debugf("Choosing webhooks based receiving") go b.handleMatterHook(mchan) + } else { + flog.Debugf("Choosing login (api) based receiving") + go b.handleMatterClient(mchan) } for message := range mchan { flog.Debugf("Sending message from %s on %s to gateway", message.Username, b.Account) |