Use downstreamConn.upstreamForCommand when handling user MODE

Provides uniform error messages.
This commit is contained in:
Simon Ser 2023-08-31 00:09:57 +09:00
parent d6fc01e44a
commit fe64c795cd

View File

@ -2012,15 +2012,11 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc.
if dc.casemap(name) == dc.nickCM { if dc.casemap(name) == dc.nickCM {
if modeStr != "" { if modeStr != "" {
if uc := dc.upstream(); uc != nil { uc, err := dc.upstreamForCommand(msg.Command)
uc.SendMessageLabeled(ctx, dc.id, msg) if err != nil {
} else { return err
dc.SendMessage(ctx, &irc.Message{
Prefix: dc.srv.prefix(),
Command: irc.ERR_UMODEUNKNOWNFLAG,
Params: []string{dc.nick, "Cannot change user mode on bouncer connection"},
})
} }
uc.SendMessageLabeled(ctx, dc.id, msg)
} else { } else {
var userMode string var userMode string
if uc := dc.upstream(); uc != nil { if uc := dc.upstream(); uc != nil {