Introduce downstreamConn.sendTargetBacklog
This commit is contained in:
parent
7e39f6d663
commit
26473ed60d
@ -979,24 +979,32 @@ func (dc *downstreamConn) messageSupportsHistory(msg *irc.Message) bool {
|
||||
}
|
||||
|
||||
func (dc *downstreamConn) sendNetworkBacklog(net *network) {
|
||||
for target := range net.delivered {
|
||||
dc.sendTargetBacklog(net, target)
|
||||
}
|
||||
}
|
||||
|
||||
func (dc *downstreamConn) sendTargetBacklog(net *network, target string) {
|
||||
if dc.caps["draft/chathistory"] || dc.user.msgStore == nil {
|
||||
return
|
||||
}
|
||||
for target, delivered := range net.delivered {
|
||||
if ch, ok := net.channels[target]; ok && ch.Detached {
|
||||
continue
|
||||
return
|
||||
}
|
||||
delivered, ok := net.delivered[target]
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
lastDelivered, ok := delivered[dc.clientName]
|
||||
if !ok {
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
limit := 4000
|
||||
history, err := dc.user.msgStore.LoadLatestID(net, target, lastDelivered, limit)
|
||||
if err != nil {
|
||||
dc.logger.Printf("failed to send implicit history for %q: %v", target, err)
|
||||
continue
|
||||
return
|
||||
}
|
||||
|
||||
batchRef := "history"
|
||||
@ -1026,7 +1034,6 @@ func (dc *downstreamConn) sendNetworkBacklog(net *network) {
|
||||
Params: []string{"-" + batchRef},
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (dc *downstreamConn) runUntilRegistered() error {
|
||||
|
Loading…
Reference in New Issue
Block a user