mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
capability: Remove CAP CLEAR as per IRCv3 recommendations, allow CAP command after registration
This commit is contained in:
parent
c3288823af
commit
5ee0f1c205
@ -12,7 +12,6 @@ const (
|
|||||||
CAP_REQ CapSubCommand = "REQ"
|
CAP_REQ CapSubCommand = "REQ"
|
||||||
CAP_ACK CapSubCommand = "ACK"
|
CAP_ACK CapSubCommand = "ACK"
|
||||||
CAP_NAK CapSubCommand = "NAK"
|
CAP_NAK CapSubCommand = "NAK"
|
||||||
CAP_CLEAR CapSubCommand = "CLEAR"
|
|
||||||
CAP_END CapSubCommand = "END"
|
CAP_END CapSubCommand = "END"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -101,11 +100,6 @@ func (msg *CapCommand) HandleRegServer(server *Server) {
|
|||||||
}
|
}
|
||||||
client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
|
client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
|
||||||
|
|
||||||
case CAP_CLEAR:
|
|
||||||
reply := RplCap(client, CAP_ACK, client.capabilities.DisableString())
|
|
||||||
client.capabilities = make(CapabilitySet)
|
|
||||||
client.Reply(reply)
|
|
||||||
|
|
||||||
case CAP_END:
|
case CAP_END:
|
||||||
client.capState = CapNegotiated
|
client.capState = CapNegotiated
|
||||||
server.tryRegister(client)
|
server.tryRegister(client)
|
||||||
@ -114,3 +108,34 @@ func (msg *CapCommand) HandleRegServer(server *Server) {
|
|||||||
client.ErrInvalidCapCmd(msg.subCommand)
|
client.ErrInvalidCapCmd(msg.subCommand)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (msg *CapCommand) HandleServer(server *Server) {
|
||||||
|
client := msg.Client()
|
||||||
|
|
||||||
|
switch msg.subCommand {
|
||||||
|
case CAP_LS:
|
||||||
|
client.Reply(RplCap(client, CAP_LS, SupportedCapabilities))
|
||||||
|
|
||||||
|
case CAP_LIST:
|
||||||
|
client.Reply(RplCap(client, CAP_LIST, client.capabilities))
|
||||||
|
|
||||||
|
case CAP_REQ:
|
||||||
|
for capability := range msg.capabilities {
|
||||||
|
if !SupportedCapabilities[capability] {
|
||||||
|
client.Reply(RplCap(client, CAP_NAK, msg.capabilities))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for capability := range msg.capabilities {
|
||||||
|
client.capabilities[capability] = true
|
||||||
|
}
|
||||||
|
client.Reply(RplCap(client, CAP_ACK, msg.capabilities))
|
||||||
|
|
||||||
|
case CAP_END:
|
||||||
|
// no-op after registration performed
|
||||||
|
return
|
||||||
|
|
||||||
|
default:
|
||||||
|
client.ErrInvalidCapCmd(msg.subCommand)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user