From 70ba7032f1d5269fb92f49cd21a32cdf16a3ca59 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 21 Mar 2022 15:09:31 +0100 Subject: [PATCH] downstream: move negotiatingCaps to downstreamRegistration This field is only relevant during connection registration. --- downstream.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/downstream.go b/downstream.go index 5ad9526..595345a 100644 --- a/downstream.go +++ b/downstream.go @@ -293,6 +293,8 @@ type downstreamRegistration struct { networkName string networkID int64 + + negotiatingCaps bool } type downstreamConn struct { @@ -313,11 +315,10 @@ type downstreamConn struct { hostname string account string // RPL_LOGGEDIN/OUT state - negotiatingCaps bool - capVersion int - caps capRegistry - sasl *downstreamSASL - registration *downstreamRegistration // nil after RPL_WELCOME + capVersion int + caps capRegistry + sasl *downstreamSASL + registration *downstreamRegistration // nil after RPL_WELCOME lastBatchRef uint64 @@ -785,7 +786,7 @@ func (dc *downstreamConn) handleMessageUnregistered(ctx context.Context, msg *ir dc.logger.Printf("unhandled message: %v", msg) return newUnknownCommandError(msg.Command) } - if dc.registration.nick != "" && dc.registration.username != "" && !dc.negotiatingCaps { + if dc.registration.nick != "" && dc.registration.username != "" && !dc.registration.negotiatingCaps { return dc.register(ctx) } return nil @@ -833,7 +834,7 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { } if !dc.registered { - dc.negotiatingCaps = true + dc.registration.negotiatingCaps = true } case "LIST": var caps []string @@ -901,10 +902,12 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error { }) if !dc.registered { - dc.negotiatingCaps = true + dc.registration.negotiatingCaps = true } case "END": - dc.negotiatingCaps = false + if !dc.registered { + dc.registration.negotiatingCaps = false + } default: return ircError{&irc.Message{ Command: err_invalidcapcmd,