From 7bfa4dafef00d0fe38c836ff2db652b523163017 Mon Sep 17 00:00:00 2001 From: Hubert Hirtz Date: Thu, 26 Nov 2020 15:41:18 +0100 Subject: [PATCH] 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. --- downstream.go | 9 +++++++++ user.go | 2 -- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/downstream.go b/downstream.go index 2f809ec..3ee0cf7 100644 --- a/downstream.go +++ b/downstream.go @@ -555,6 +555,14 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { 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)) for k, v := range dc.supportedCaps { @@ -896,6 +904,7 @@ func (dc *downstreamConn) welcome() error { }) dc.updateNick() + dc.updateSupportedCaps() dc.forEachUpstream(func(uc *upstreamConn) { for _, ch := range uc.channels { diff --git a/user.go b/user.go index 6d54ffc..4118ea5 100644 --- a/user.go +++ b/user.go @@ -435,8 +435,6 @@ func (u *user) run() { u.forEachUpstream(func(uc *upstreamConn) { uc.updateAway() }) - - dc.updateSupportedCaps() case eventDownstreamDisconnected: dc := e.dc