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

Merge pull request #991 from ajaspers/who_invisible

Hide +i users from WHO * queries.
This commit is contained in:
Shivaram Lingamneni 2020-05-07 19:09:38 -07:00 committed by GitHub
commit d187cc5512
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2637,8 +2637,30 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
}
}
} else {
// Construct set of channels the client is in.
userChannels := make(map[*Channel]bool)
for _, channel := range client.Channels() {
userChannels[channel] = true
}
// Another client is a friend if they share at least one channel, or they are the same client.
isFriend := func(otherClient *Client) bool {
if client == otherClient {
return true
}
for _, channel := range otherClient.Channels() {
if userChannels[channel] {
return true
}
}
return false
}
for mclient := range server.clients.FindAll(mask) {
client.rplWhoReply(nil, mclient, rb)
if isOper || !mclient.HasMode(modes.Invisible) || isFriend(mclient) {
client.rplWhoReply(nil, mclient, rb)
}
}
}