Unify away-notify and account-notify handling

This commit is contained in:
Simon Ser 2021-10-17 21:53:18 +02:00
parent 455fef2421
commit 324d0fb0ac
2 changed files with 5 additions and 16 deletions

View File

@ -410,6 +410,10 @@ func (dc *downstreamConn) SendMessage(msg *irc.Message) {
if msg.Command == "SETNAME" && !dc.caps["setname"] {
return
}
if msg.Command == "AWAY" && !dc.caps["away-notify"] {
// TODO: we can send AWAY if we just sent a PRIVMSG/NOTICE to this user
return
}
if msg.Command == "ACCOUNT" && !dc.caps["account-notify"] {
return
}

View File

@ -1371,22 +1371,7 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
Params: []string{dc.nick, dc.marshalEntity(uc.network, nick), reason},
})
})
case "AWAY":
if msg.Prefix == nil {
return fmt.Errorf("expected a prefix")
}
uc.forEachDownstream(func(dc *downstreamConn) {
if !dc.caps["away-notify"] {
return
}
dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc.network, msg.Prefix),
Command: "AWAY",
Params: msg.Params,
})
})
case "ACCOUNT":
case "AWAY", "ACCOUNT":
if msg.Prefix == nil {
return fmt.Errorf("expected a prefix")
}