Add downstreamConn.isMultiUpstream

This commit is contained in:
Simon Ser 2021-11-17 11:17:09 +01:00
parent 73295e4fa7
commit ff44ea314e
2 changed files with 9 additions and 5 deletions

View File

@ -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,

View File

@ -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 {