Show users in WHO queries if they are friends, i.e. they share a channel.

This commit is contained in:
Alex Jaspersen 2020-05-07 03:00:28 +00:00
parent 1ef41d6020
commit b3cfcc1289
2 changed files with 16 additions and 1 deletions

View File

@ -1022,6 +1022,21 @@ func (client *Client) ModeString() (str string) {
return "+" + client.modes.String()
}
// IsFriend() returns true if the given otherClient shares a channel with this client, or if they are the same user.
func (client *Client) IsFriend(otherClient *Client) bool {
if client == otherClient {
return true
}
for _, channel := range client.Channels() {
if channel.hasClient(otherClient) {
return true
}
}
return false
}
// Friends refers to clients that share a channel with this client.
func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool) {
result = make(map[*Session]bool)

View File

@ -2637,7 +2637,7 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
}
} else {
for mclient := range server.clients.FindAll(mask) {
if !mclient.HasMode(modes.Invisible) || isOper {
if isOper || !mclient.HasMode(modes.Invisible) || mclient.IsFriend(client) {
client.rplWhoReply(nil, mclient, rb)
}
}