Browse Source

Merge pull request #991 from ajaspers/who_invisible

Hide +i users from WHO * queries.
tags/v2.1.0-rc1
Shivaram Lingamneni 4 years ago
parent
commit
d187cc5512
No account linked to committer's email address
1 changed files with 23 additions and 1 deletions
  1. 23
    1
      irc/handlers.go

+ 23
- 1
irc/handlers.go View File

@@ -2637,8 +2637,30 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
2637 2637
 			}
2638 2638
 		}
2639 2639
 	} else {
2640
+		// Construct set of channels the client is in.
2641
+		userChannels := make(map[*Channel]bool)
2642
+		for _, channel := range client.Channels() {
2643
+			userChannels[channel] = true
2644
+		}
2645
+
2646
+		// Another client is a friend if they share at least one channel, or they are the same client.
2647
+		isFriend := func(otherClient *Client) bool {
2648
+			if client == otherClient {
2649
+				return true
2650
+			}
2651
+
2652
+			for _, channel := range otherClient.Channels() {
2653
+				if userChannels[channel] {
2654
+					return true
2655
+				}
2656
+			}
2657
+			return false
2658
+		}
2659
+
2640 2660
 		for mclient := range server.clients.FindAll(mask) {
2641
-			client.rplWhoReply(nil, mclient, rb)
2661
+			if isOper || !mclient.HasMode(modes.Invisible) || isFriend(mclient) {
2662
+				client.rplWhoReply(nil, mclient, rb)
2663
+			}
2642 2664
 		}
2643 2665
 	}
2644 2666
 

Loading…
Cancel
Save