From ff44ea314e72409fd5111ba3b3f34428d609cd88 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Wed, 17 Nov 2021 11:17:09 +0100 Subject: [PATCH] Add downstreamConn.isMultiUpstream --- downstream.go | 12 ++++++++---- user.go | 2 +- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/downstream.go b/downstream.go index af91df3..6ee1129 100644 --- a/downstream.go +++ b/downstream.go @@ -307,16 +307,20 @@ func (dc *downstreamConn) prefix() *irc.Prefix { } } +func (dc *downstreamConn) isMultiUpstream() bool { + return dc.network == nil && !dc.caps["soju.im/bouncer-networks"] +} + func (dc *downstreamConn) forEachNetwork(f func(*network)) { if dc.network != nil { f(dc.network) - } else if !dc.caps["soju.im/bouncer-networks"] { + } else if dc.isMultiUpstream() { dc.user.forEachNetwork(f) } } func (dc *downstreamConn) forEachUpstream(f func(*upstreamConn)) { - if dc.network == nil && dc.caps["soju.im/bouncer-networks"] { + if dc.network == nil && !dc.isMultiUpstream() { return } dc.user.forEachUpstream(func(uc *upstreamConn) { @@ -1181,7 +1185,7 @@ func (dc *downstreamConn) welcome() error { if title := dc.srv.Config().Title; dc.network == nil && title != "" { isupport = append(isupport, "NETWORK="+encodeISUPPORT(title)) } - if dc.network == nil && dc.caps["soju.im/bouncer-networks"] { + if dc.network == nil && !dc.isMultiUpstream() { isupport = append(isupport, "WHOX") } @@ -1224,7 +1228,7 @@ func (dc *downstreamConn) welcome() error { Params: []string{dc.nick, "+" + string(uc.modes)}, }) } - if dc.network == nil && dc.caps["soju.im/bouncer-networks"] && dc.user.Admin { + if dc.network == nil && !dc.isMultiUpstream() && dc.user.Admin { dc.SendMessage(&irc.Message{ Prefix: dc.srv.prefix(), Command: irc.RPL_UMODEIS, diff --git a/user.go b/user.go index a1e9199..90cb11e 100644 --- a/user.go +++ b/user.go @@ -152,7 +152,7 @@ func newNetwork(user *user, record *Network, channels []Channel) *network { func (net *network) forEachDownstream(f func(*downstreamConn)) { net.user.forEachDownstream(func(dc *downstreamConn) { - if dc.network == nil && dc.caps["soju.im/bouncer-networks"] { + if dc.network == nil && !dc.isMultiUpstream() { return } if dc.network != nil && dc.network != net {