From b49552ed5b07d82147ffa382d2df427c9077fb6d Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Tue, 3 Oct 2023 12:01:59 +0200 Subject: [PATCH] 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. --- user.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/user.go b/user.go index 581433a..588e015 100644 --- a/user.go +++ b/user.go @@ -910,6 +910,18 @@ func (u *user) handleUpstreamDisconnected(uc *upstreamConn) { } 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) for _, dc := range u.downstreamConns { if dc.caps.IsEnabled("soju.im/bouncer-networks-notify") {