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.
This commit is contained in:
Simon Ser 2021-03-29 17:07:39 +02:00
parent 55274d7213
commit 07519da768

View File

@ -1001,14 +1001,14 @@ func (dc *downstreamConn) welcome() error {
} }
// Fast-forward history to last message // Fast-forward history to last message
for target, entry := range net.delivered.innerMap { for targetCM, entry := range net.delivered.innerMap {
delivered := entry.value.(deliveredClientMap) delivered := entry.value.(deliveredClientMap)
ch := net.channels.Value(target) ch := net.channels.Value(targetCM)
if ch != nil && ch.Detached { if ch != nil && ch.Detached {
continue continue
} }
lastID, err := dc.user.msgStore.LastMsgID(net, target, time.Now()) lastID, err := dc.user.msgStore.LastMsgID(net, targetCM, time.Now())
if err != nil { if err != nil {
dc.logger.Printf("failed to get last message ID: %v", err) dc.logger.Printf("failed to get last message ID: %v", err)
continue continue
@ -1058,7 +1058,8 @@ func (dc *downstreamConn) sendTargetBacklog(net *network, target string) {
} }
limit := 4000 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 { if err != nil {
dc.logger.Printf("failed to send implicit history for %q: %v", target, err) dc.logger.Printf("failed to send implicit history for %q: %v", target, err)
return return