From 6513136ea3cf19af58cec99d883a1c87b9eaf976 Mon Sep 17 00:00:00 2001 From: Shivaram Lingamneni Date: Thu, 29 Oct 2020 14:25:28 -0400 Subject: [PATCH] fix #1366 Include an 'r' flag in RPL_WHOREPLY for registered nicks --- irc/handlers.go | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/irc/handlers.go b/irc/handlers.go index 1a79df9f..fd6581fb 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -3049,7 +3049,7 @@ func (fields whoxFields) Has(field rune) bool { // [*][~|&|@|%|+][B] : // whox format: // [*][~|&|@|%|+][B] : -func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, hasPrivs, isWhox bool, fields whoxFields, whoType string) { +func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *ResponseBuffer, hasPrivs, includeRFlag, isWhox bool, fields whoxFields, whoType string) { params := []string{client.Nick()} details := target.Details() @@ -3104,6 +3104,10 @@ func (client *Client) rplWhoReply(channel *Channel, target *Client, rb *Response flags.WriteRune('B') } + if includeRFlag && details.account != "" { + flags.WriteRune('r') + } + params = append(params, flags.String()) } @@ -3157,6 +3161,13 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo return false } + // include the r flag only if nick and account are synonymous + config := server.Config() + includeRFlag := config.Accounts.NickReservation.Enabled && + config.Accounts.NickReservation.Method == NickEnforcementStrict && + !config.Accounts.NickReservation.AllowCustomEnforcement && + config.Accounts.NickReservation.ForceNickEqualsAccount + sFields := "cuhsnf" whoType := "0" isWhox := false @@ -3200,7 +3211,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo } for _, member := range members { if !member.HasMode(modes.Invisible) || isJoined || isOper { - client.rplWhoReply(channel, member, rb, isOper, isWhox, fields, whoType) + client.rplWhoReply(channel, member, rb, isOper, includeRFlag, isWhox, fields, whoType) } } } @@ -3231,7 +3242,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo for mclient := range server.clients.FindAll(mask) { if isOper || !mclient.HasMode(modes.Invisible) || isFriend(mclient) { - client.rplWhoReply(nil, mclient, rb, isOper, isWhox, fields, whoType) + client.rplWhoReply(nil, mclient, rb, isOper, includeRFlag, isWhox, fields, whoType) } } }