Fix upstream NICK handling

- uc.nicl was compared to msg.Prefix.Name after being updated to the new
  nick
- The new nick wasn't marshaled
This commit is contained in:
Simon Ser 2020-04-07 15:01:11 +02:00
parent f4aa05af66
commit 37cd9e4d89
No known key found for this signature in database
GPG Key ID: 0FDE7BE0E88F5E48

View File

@ -546,8 +546,10 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
return err return err
} }
me := false
if msg.Prefix.Name == uc.nick { if msg.Prefix.Name == uc.nick {
uc.logger.Printf("changed nick from %q to %q", uc.nick, newNick) uc.logger.Printf("changed nick from %q to %q", uc.nick, newNick)
me = true
uc.nick = newNick uc.nick = newNick
} }
@ -559,12 +561,12 @@ func (uc *upstreamConn) handleMessage(msg *irc.Message) error {
} }
} }
if msg.Prefix.Name != uc.nick { if !me {
uc.forEachDownstream(func(dc *downstreamConn) { uc.forEachDownstream(func(dc *downstreamConn) {
dc.SendMessage(&irc.Message{ dc.SendMessage(&irc.Message{
Prefix: dc.marshalUserPrefix(uc, msg.Prefix), Prefix: dc.marshalUserPrefix(uc, msg.Prefix),
Command: "NICK", Command: "NICK",
Params: []string{newNick}, Params: []string{dc.marshalEntity(uc, newNick)},
}) })
}) })
} }