Advertise all caps, CAP DEL them on registration

... so that the JOIN/history batch takes into account all capabilities.
Without this commit for example, enabling multi-prefix after the batch
makes the client send NAMES requests for all channels, which generate
needless traffic.
This commit is contained in:
Hubert Hirtz 2020-11-26 15:41:18 +01:00 committed by Simon Ser
parent 0ddc0de7e5
commit 7bfa4dafef
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48
2 changed files with 9 additions and 2 deletions

View File

@ -555,6 +555,14 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
return err return err
} }
} }
if !dc.registered && dc.capVersion >= 302 {
// Let downstream show everything it supports, and trim
// down the available capabilities when upstreams are
// known.
for k, v := range needAllDownstreamCaps {
dc.supportedCaps[k] = v
}
}
caps := make([]string, 0, len(dc.supportedCaps)) caps := make([]string, 0, len(dc.supportedCaps))
for k, v := range dc.supportedCaps { for k, v := range dc.supportedCaps {
@ -896,6 +904,7 @@ func (dc *downstreamConn) welcome() error {
}) })
dc.updateNick() dc.updateNick()
dc.updateSupportedCaps()
dc.forEachUpstream(func(uc *upstreamConn) { dc.forEachUpstream(func(uc *upstreamConn) {
for _, ch := range uc.channels { for _, ch := range uc.channels {

View File

@ -435,8 +435,6 @@ func (u *user) run() {
u.forEachUpstream(func(uc *upstreamConn) { u.forEachUpstream(func(uc *upstreamConn) {
uc.updateAway() uc.updateAway()
}) })
dc.updateSupportedCaps()
case eventDownstreamDisconnected: case eventDownstreamDisconnected:
dc := e.dc dc := e.dc