downstream: move negotiatingCaps to downstreamRegistration

This field is only relevant during connection registration.
This commit is contained in:
Simon Ser 2022-03-21 15:09:31 +01:00
parent 884bfec6a6
commit 70ba7032f1

View File

@ -293,6 +293,8 @@ type downstreamRegistration struct {
networkName string networkName string
networkID int64 networkID int64
negotiatingCaps bool
} }
type downstreamConn struct { type downstreamConn struct {
@ -313,11 +315,10 @@ type downstreamConn struct {
hostname string hostname string
account string // RPL_LOGGEDIN/OUT state account string // RPL_LOGGEDIN/OUT state
negotiatingCaps bool capVersion int
capVersion int caps capRegistry
caps capRegistry sasl *downstreamSASL
sasl *downstreamSASL registration *downstreamRegistration // nil after RPL_WELCOME
registration *downstreamRegistration // nil after RPL_WELCOME
lastBatchRef uint64 lastBatchRef uint64
@ -785,7 +786,7 @@ func (dc *downstreamConn) handleMessageUnregistered(ctx context.Context, msg *ir
dc.logger.Printf("unhandled message: %v", msg) dc.logger.Printf("unhandled message: %v", msg)
return newUnknownCommandError(msg.Command) 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 dc.register(ctx)
} }
return nil return nil
@ -833,7 +834,7 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
} }
if !dc.registered { if !dc.registered {
dc.negotiatingCaps = true dc.registration.negotiatingCaps = true
} }
case "LIST": case "LIST":
var caps []string var caps []string
@ -901,10 +902,12 @@ func (dc *downstreamConn) handleCapCommand(cmd string, args []string) error {
}) })
if !dc.registered { if !dc.registered {
dc.negotiatingCaps = true dc.registration.negotiatingCaps = true
} }
case "END": case "END":
dc.negotiatingCaps = false if !dc.registered {
dc.registration.negotiatingCaps = false
}
default: default:
return ircError{&irc.Message{ return ircError{&irc.Message{
Command: err_invalidcapcmd, Command: err_invalidcapcmd,