upstream: improve server message detection

Stop relying on user/host being unset: this is fragile, some servers
send messages coming from users without these.
This commit is contained in:
Simon Ser 2022-06-24 13:41:37 +02:00
parent ebe209b3a4
commit ca3557d9ef

View File

@ -503,9 +503,12 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
break
}
if msg.Prefix.User == "" && msg.Prefix.Host == "" { // server message
if msg.Prefix.Name == uc.serverPrefix.Name || msg.Prefix.Name == "*" || strings.HasPrefix(target, "$") {
// This is a server message
uc.produce("", msg, 0)
} else { // regular user message
break
}
bufferName := target
if uc.isOurNick(target) {
bufferName = msg.Prefix.Name
@ -532,7 +535,6 @@ func (uc *upstreamConn) handleMessage(ctx context.Context, msg *irc.Message) err
}
uc.produce(bufferName, msg, downstreamID)
}
case "CAP":
var subCmd string
if err := parseMessageParams(msg, nil, &subCmd); err != nil {