3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-25 05:19:25 +01:00

Merge pull request #1992 from slingamn/issue1991_who.1

fix #1991
This commit is contained in:
Shivaram Lingamneni 2022-08-22 20:07:44 -07:00 committed by GitHub
commit 7d6ff58bf8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3435,12 +3435,21 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
return false
}
// https://modern.ircdocs.horse/#who-message
// "1. A channel name, in which case the channel members are listed."
// "2. An exact nickname, in which case a single user is returned."
// "3. A mask pattern, in which case all visible users whose nickname matches are listed."
var isChannel bool
var isBareNick bool
mask := origMask
var err error
if mask[0] == '#' {
mask, err = CasefoldChannel(msg.Params[0])
if origMask[0] == '#' {
mask, err = CasefoldChannel(origMask)
isChannel = true
} else if !strings.ContainsAny(origMask, protocolBreakingNameCharacters) {
isBareNick = true
} else {
mask, err = CanonicalizeMaskWildcard(mask)
mask, err = CanonicalizeMaskWildcard(origMask)
}
if err != nil {
@ -3491,7 +3500,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
oper := client.Oper()
hasPrivs := oper.HasRoleCapab("sajoin")
canSeeIPs := oper.HasRoleCapab("ban")
if mask[0] == '#' {
if isChannel {
channel := server.channels.Get(mask)
if channel != nil {
isJoined := channel.hasClient(client)
@ -3509,6 +3518,11 @@ func whoHandler(server *Server, client *Client, msg ircmsg.Message, rb *Response
}
}
}
} else if isBareNick {
mclient := server.clients.Get(mask)
if mclient != nil {
client.rplWhoReply(nil, mclient, rb, canSeeIPs, oper != nil, includeRFlag, isWhox, fields, whoType)
}
} else {
// Construct set of channels the client is in.
userChannels := make(ChannelSet)