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
networkID int64
negotiatingCaps bool
}
type downstreamConn struct {
@ -313,7 +315,6 @@ type downstreamConn struct {
hostname string
account string // RPL_LOGGEDIN/OUT state
negotiatingCaps bool
capVersion int
caps capRegistry
sasl *downstreamSASL
@ -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,