From fe64c795cda3ecb33a1c68ca91d0d75869226175 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 31 Aug 2023 00:09:57 +0900 Subject: [PATCH] Use downstreamConn.upstreamForCommand when handling user MODE Provides uniform error messages. --- downstream.go | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/downstream.go b/downstream.go index 66d478f..4b9f72e 100644 --- a/downstream.go +++ b/downstream.go @@ -2012,15 +2012,11 @@ func (dc *downstreamConn) handleMessageRegistered(ctx context.Context, msg *irc. if dc.casemap(name) == dc.nickCM { if modeStr != "" { - if uc := dc.upstream(); uc != nil { - uc.SendMessageLabeled(ctx, dc.id, msg) - } else { - 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, err := dc.upstreamForCommand(msg.Command) + if err != nil { + return err } + uc.SendMessageLabeled(ctx, dc.id, msg) } else { var userMode string if uc := dc.upstream(); uc != nil {