3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-12-26 12:42:50 +01:00

Merge pull request #1367 from slingamn/registered_flag_whoreply

fix #1366
This commit is contained in:
Shivaram Lingamneni 2020-10-30 08:42:35 -07:00 committed by GitHub
commit 42ae35d266
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3049,7 +3049,7 @@ func (fields whoxFields) Has(field rune) bool {
// <channel> <user> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] :<hopcount> <real name>
// whox format:
// <type> <channel> <user> <ip> <host> <server> <nick> <H|G>[*][~|&|@|%|+][B] <hops> <idle> <account> <rank> :<real name>
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)
}
}
}