From 2f7df2df432b3619a95e7eb6b3d8e511b105d5cf Mon Sep 17 00:00:00 2001 From: Wim Date: Tue, 29 Aug 2017 20:28:44 +0200 Subject: Do not add messages without ID to cache --- bridge/gitter/gitter.go | 2 +- gateway/gateway.go | 4 +++- gateway/router.go | 2 +- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/bridge/gitter/gitter.go b/bridge/gitter/gitter.go index 829be592..98aba865 100644 --- a/bridge/gitter/gitter.go +++ b/bridge/gitter/gitter.go @@ -105,8 +105,8 @@ func (b *Bgitter) Send(msg config.Message) (string, error) { flog.Errorf("Could not find roomID for %v", msg.Channel) return "", nil } - // add ZWSP because gitter echoes our own messages if msg.ID != "" { + flog.Debugf("updating message with id %s", msg.ID) _, err := b.c.UpdateMessage(roomID, msg.ID, msg.Username+msg.Text) if err != nil { return "", err diff --git a/gateway/gateway.go b/gateway/gateway.go index aca8ecec..d09741fa 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -186,7 +186,9 @@ func (gw *Gateway) handleMessage(msg config.Message, dest *bridge.Bridge) []*BrM fmt.Println(err) } // append the message ID (mID) from this bridge (dest) to our brMsgIDs slice - brMsgIDs = append(brMsgIDs, &BrMsgID{dest, mID}) + if mID != "" { + brMsgIDs = append(brMsgIDs, &BrMsgID{dest, mID}) + } } return brMsgIDs } diff --git a/gateway/router.go b/gateway/router.go index 56518e6c..28f81335 100644 --- a/gateway/router.go +++ b/gateway/router.go @@ -103,7 +103,7 @@ func (r *Router) handleReceive() { msgIDs = append(msgIDs, gw.handleMessage(msg, br)...) } // only add the message ID if it doesn't already exists - if _, ok := gw.Messages.Get(msg.ID); !ok { + if _, ok := gw.Messages.Get(msg.ID); !ok && msg.ID != "" { gw.Messages.Add(msg.ID, msgIDs) } } -- cgit v1.2.3