diff options
author | Wim <wim@42.be> | 2018-05-27 21:50:00 +0200 |
---|---|---|
committer | Wim <wim@42.be> | 2018-05-27 21:50:00 +0200 |
commit | 411ef2691ccec024cf6b952e42d3f4564cb9ec58 (patch) | |
tree | 8de87bbc239f3efcafcc1275e8678f47a7d51ebb /bridge/mattermost | |
parent | fc6074ea9fba9684aaad1ab6d43a0ec23db8c5d3 (diff) | |
download | matterbridge-msglm-411ef2691ccec024cf6b952e42d3f4564cb9ec58.tar.gz matterbridge-msglm-411ef2691ccec024cf6b952e42d3f4564cb9ec58.tar.bz2 matterbridge-msglm-411ef2691ccec024cf6b952e42d3f4564cb9ec58.zip |
Use uuid instead of userid. Fixes #429
Diffstat (limited to 'bridge/mattermost')
-rw-r--r-- | bridge/mattermost/mattermost.go | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/bridge/mattermost/mattermost.go b/bridge/mattermost/mattermost.go index 42843d00..51d32424 100644 --- a/bridge/mattermost/mattermost.go +++ b/bridge/mattermost/mattermost.go @@ -8,12 +8,14 @@ import ( "github.com/42wim/matterbridge/bridge/helper" "github.com/42wim/matterbridge/matterclient" "github.com/42wim/matterbridge/matterhook" + "github.com/rs/xid" "strings" ) type Bmattermost struct { mh *matterhook.Client mc *matterclient.MMClient + uuid string TeamID string *bridge.Config avatarMap map[string]string @@ -21,6 +23,7 @@ type Bmattermost struct { func New(cfg *bridge.Config) bridge.Bridger { b := &Bmattermost{Config: cfg, avatarMap: make(map[string]string)} + b.uuid = xid.New().String() return b } @@ -366,7 +369,7 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) { // this sends a message only if we received a config.EVENT_FILE_FAILURE_SIZE for _, rmsg := range helper.HandleExtra(&msg, b.General) { matterMessage := matterhook.OMessage{IconURL: b.GetString("IconURL"), Channel: rmsg.Channel, UserName: rmsg.Username, Text: rmsg.Text, Props: make(map[string]interface{})} - matterMessage.Props["matterbridge_"+b.mc.User.Id] = true + matterMessage.Props["matterbridge_"+b.uuid] = true b.mh.Send(matterMessage) } @@ -385,7 +388,7 @@ func (b *Bmattermost) sendWebhook(msg config.Message) (string, error) { if msg.Avatar != "" { matterMessage.IconURL = msg.Avatar } - matterMessage.Props["matterbridge_"+b.mc.User.Id] = true + matterMessage.Props["matterbridge_"+b.uuid] = true err := b.mh.Send(matterMessage) if err != nil { b.Log.Info(err) @@ -415,7 +418,7 @@ func (b *Bmattermost) skipMessage(message *matterclient.Message) bool { // Ignore messages sent from matterbridge if message.Post.Props != nil { - if _, ok := message.Post.Props["matterbridge_"+b.mc.User.Id].(bool); ok { + if _, ok := message.Post.Props["matterbridge_"+b.uuid].(bool); ok { b.Log.Debugf("sent by matterbridge, ignoring") return true } |