Broadcast BOUNCER notifications to all downstream connections

We weren't sending them to downstreams which weren't bound to a
network.
This commit is contained in:
Simon Ser 2021-05-26 11:04:33 +02:00
parent 7d648f702e
commit b0349caada

16
user.go
View File

@ -522,18 +522,21 @@ func (u *user) run() {
uc.forEachDownstream(func(dc *downstreamConn) { uc.forEachDownstream(func(dc *downstreamConn) {
dc.updateSupportedCaps() dc.updateSupportedCaps()
if !dc.caps["soju.im/bouncer-networks"] {
sendServiceNOTICE(dc, fmt.Sprintf("connected to %s", uc.network.GetName()))
}
dc.updateNick()
dc.updateRealname()
})
u.forEachDownstream(func(dc *downstreamConn) {
if dc.caps["soju.im/bouncer-networks-notify"] { if dc.caps["soju.im/bouncer-networks-notify"] {
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),
Command: "BOUNCER", Command: "BOUNCER",
Params: []string{"NETWORK", netIDStr, "status=connected"}, Params: []string{"NETWORK", netIDStr, "status=connected"},
}) })
} else if !dc.caps["soju.im/bouncer-networks"] {
sendServiceNOTICE(dc, fmt.Sprintf("connected to %s", uc.network.GetName()))
} }
dc.updateNick()
dc.updateRealname()
}) })
uc.network.lastError = nil uc.network.lastError = nil
case eventUpstreamDisconnected: case eventUpstreamDisconnected:
@ -661,7 +664,8 @@ func (u *user) handleUpstreamDisconnected(uc *upstreamConn) {
netIDStr := fmt.Sprintf("%v", uc.network.ID) netIDStr := fmt.Sprintf("%v", uc.network.ID)
uc.forEachDownstream(func(dc *downstreamConn) { uc.forEachDownstream(func(dc *downstreamConn) {
dc.updateSupportedCaps() dc.updateSupportedCaps()
})
u.forEachDownstream(func(dc *downstreamConn) {
if dc.caps["soju.im/bouncer-networks-notify"] { if dc.caps["soju.im/bouncer-networks-notify"] {
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.srv.prefix(), Prefix: dc.srv.prefix(),