fix wrong matching on listener remove when router is used.

pablo's crash, see https://t.me/nip29_temp/670
This commit is contained in:
fiatjaf
2024-08-13 13:21:39 -03:00
parent 3b03f6700c
commit 3e6d763a79

View File

@@ -121,7 +121,7 @@ func (rl *Relay) removeClientAndListeners(ws *WebSocket) {
// so its .index reflects its new position on srl.listeners
movedSpecs := rl.clients[moved.ws]
idx := slices.IndexFunc(movedSpecs, func(ls listenerSpec) bool {
return ls.index == movedFromIndex
return ls.index == movedFromIndex && ls.subrelay == srl
})
movedSpecs[idx].index = spec.index
rl.clients[moved.ws] = movedSpecs