From 07519da768a938d88131c9ed66db23792dee7503 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 29 Mar 2021 17:07:39 +0200 Subject: [PATCH] Ensure targets are case-mapped before being passed to messageStore messageStore isn't aware of the network's case-mapping. We need to canonicalize the names before passing them to messageStore. --- downstream.go | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/downstream.go b/downstream.go index 347d042..2a3336d 100644 --- a/downstream.go +++ b/downstream.go @@ -1001,14 +1001,14 @@ func (dc *downstreamConn) welcome() error { } // Fast-forward history to last message - for target, entry := range net.delivered.innerMap { + for targetCM, entry := range net.delivered.innerMap { delivered := entry.value.(deliveredClientMap) - ch := net.channels.Value(target) + ch := net.channels.Value(targetCM) if ch != nil && ch.Detached { continue } - lastID, err := dc.user.msgStore.LastMsgID(net, target, time.Now()) + lastID, err := dc.user.msgStore.LastMsgID(net, targetCM, time.Now()) if err != nil { dc.logger.Printf("failed to get last message ID: %v", err) continue @@ -1058,7 +1058,8 @@ func (dc *downstreamConn) sendTargetBacklog(net *network, target string) { } limit := 4000 - history, err := dc.user.msgStore.LoadLatestID(net, target, lastDelivered, limit) + targetCM := net.casemap(target) + history, err := dc.user.msgStore.LoadLatestID(net, targetCM, lastDelivered, limit) if err != nil { dc.logger.Printf("failed to send implicit history for %q: %v", target, err) return