diff --git a/gateway/gateway.go b/gateway/gateway.go index 2874ef24..b329e7aa 100644 --- a/gateway/gateway.go +++ b/gateway/gateway.go @@ -66,7 +66,7 @@ func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string { v, _ := gw.Messages.Peek(mid) ids := v.([]*BrMsgID) for _, downstreamMsgObj := range ids { - if ID == downstreamMsgObj.ID { + if normalizeID(ID) == normalizeID(downstreamMsgObj.ID) { return strings.Replace(mid.(string), protocol+" ", "", 1) } } @@ -74,6 +74,18 @@ func (gw *Gateway) FindCanonicalMsgID(protocol string, mID string) string { return "" } +// Allows matches independant of protocol, +// eg: slack vs slack-legacy +func normalizeID(id string) string { + fields := strings.Fields(id) + if len(fields) != 2 { + return id + } + protocol, mID := fields[0], fields[1] + baseProtocol := strings.Split(protocol, "-")[0] + return baseProtocol+" "+mID +} + func (gw *Gateway) AddBridge(cfg *config.Bridge) error { br := gw.Router.getBridge(cfg.Account) if br == nil {