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

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() 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. // Friends refers to clients that share a channel with this client.
func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool) { func (client *Client) Friends(capabs ...caps.Capability) (result map[*Session]bool) {
result = make(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 { } else {
for mclient := range server.clients.FindAll(mask) { 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) client.rplWhoReply(nil, mclient, rb)
} }
} }