From 53aa0765554a899ba57acd4cb7086b4e69fe8ac8 Mon Sep 17 00:00:00 2001 From: Wim Date: Sat, 2 Mar 2019 22:58:14 +0100 Subject: Do not send duplicate messages (rocketchat). Fixes #745 (#752) For an unknown reason we get duplicate messages (from the same channel) using the realtime API when we have > 1 channel subscribed on. Solution for now is caching the message ID in a LRU cache and ignoring the duplicates. This should be reviewed when we have actual editing support from the realtime API --- bridge/rocketchat/handlers.go | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'bridge/rocketchat/handlers.go') diff --git a/bridge/rocketchat/handlers.go b/bridge/rocketchat/handlers.go index b44ea46f..a41004d4 100644 --- a/bridge/rocketchat/handlers.go +++ b/bridge/rocketchat/handlers.go @@ -40,6 +40,11 @@ func (b *Brocketchat) handleRocketHook(messages chan *config.Message) { func (b *Brocketchat) handleRocketClient(messages chan *config.Message) { for message := range b.messageChan { + // skip messages with same ID, apparently messages get duplicated for an unknown reason + if _, ok := b.cache.Get(message.ID); ok { + continue + } + b.cache.Add(message.ID, true) b.Log.Debugf("message %#v", message) m := message if b.skipMessage(&m) { -- cgit v1.2.3