Don't send bouncer-networks updates for removed networks

We may asynchronously receive an upstream's connection status after
the network has been removed.

Sending an update is pretty bad since it's interpreted by clients
as a new network.
This commit is contained in:
Simon Ser 2023-10-03 12:01:59 +02:00
parent 73e594d59d
commit b49552ed5b

12
user.go
View File

@ -910,6 +910,18 @@ func (u *user) handleUpstreamDisconnected(uc *upstreamConn) {
} }
func (u *user) notifyBouncerNetworkState(netID int64, attrs irc.Tags) { func (u *user) notifyBouncerNetworkState(netID int64, attrs irc.Tags) {
// Don't send state updates for removed networks
found := false
for _, net := range u.networks {
if net.ID == netID {
found = true
break
}
}
if !found {
return
}
netIDStr := fmt.Sprintf("%v", netID) netIDStr := fmt.Sprintf("%v", netID)
for _, dc := range u.downstreamConns { for _, dc := range u.downstreamConns {
if dc.caps.IsEnabled("soju.im/bouncer-networks-notify") { if dc.caps.IsEnabled("soju.im/bouncer-networks-notify") {