Browse Source

tweaks to NAMES / WHO privacy

tags/v1.1.0-rc1
Shivaram Lingamneni 5 years ago
parent
commit
74afeaed55
2 changed files with 11 additions and 6 deletions
  1. 3
    2
      irc/channel.go
  2. 8
    4
      irc/handlers.go

+ 3
- 2
irc/channel.go View File

336
 // Names sends the list of users joined to the channel to the given client.
336
 // Names sends the list of users joined to the channel to the given client.
337
 func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
337
 func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
338
 	isJoined := channel.hasClient(client)
338
 	isJoined := channel.hasClient(client)
339
+	isOper := client.HasMode(modes.Operator)
339
 	isMultiPrefix := rb.session.capabilities.Has(caps.MultiPrefix)
340
 	isMultiPrefix := rb.session.capabilities.Has(caps.MultiPrefix)
340
 	isUserhostInNames := rb.session.capabilities.Has(caps.UserhostInNames)
341
 	isUserhostInNames := rb.session.capabilities.Has(caps.UserhostInNames)
341
 
342
 
342
 	maxNamLen := 480 - len(client.server.name) - len(client.Nick())
343
 	maxNamLen := 480 - len(client.server.name) - len(client.Nick())
343
 	var namesLines []string
344
 	var namesLines []string
344
 	var buffer bytes.Buffer
345
 	var buffer bytes.Buffer
345
-	if isJoined || !channel.flags.HasMode(modes.Secret) {
346
+	if isJoined || !channel.flags.HasMode(modes.Secret) || isOper {
346
 		for _, target := range channel.Members() {
347
 		for _, target := range channel.Members() {
347
 			var nick string
348
 			var nick string
348
 			if isUserhostInNames {
349
 			if isUserhostInNames {
356
 			if modeSet == nil {
357
 			if modeSet == nil {
357
 				continue
358
 				continue
358
 			}
359
 			}
359
-			if !isJoined && target.flags.HasMode(modes.Invisible) {
360
+			if !isJoined && target.flags.HasMode(modes.Invisible) && !isOper {
360
 				continue
361
 				continue
361
 			}
362
 			}
362
 			prefix := modeSet.Prefixes(isMultiPrefix)
363
 			prefix := modeSet.Prefixes(isMultiPrefix)

+ 8
- 4
irc/handlers.go View File

2595
 	//	operatorOnly = true
2595
 	//	operatorOnly = true
2596
 	//}
2596
 	//}
2597
 
2597
 
2598
+	isOper := client.HasMode(modes.Operator)
2598
 	if mask[0] == '#' {
2599
 	if mask[0] == '#' {
2599
 		// TODO implement wildcard matching
2600
 		// TODO implement wildcard matching
2600
 		//TODO(dan): ^ only for opers
2601
 		//TODO(dan): ^ only for opers
2601
 		channel := server.channels.Get(mask)
2602
 		channel := server.channels.Get(mask)
2602
-		if channel != nil && channel.hasClient(client) {
2603
-			for _, member := range channel.Members() {
2604
-				if !member.HasMode(modes.Invisible) {
2605
-					client.rplWhoReply(channel, member, rb)
2603
+		if channel != nil {
2604
+			isJoined := channel.hasClient(client)
2605
+			if !channel.flags.HasMode(modes.Secret) || isJoined || isOper {
2606
+				for _, member := range channel.Members() {
2607
+					if !member.HasMode(modes.Invisible) || isJoined || isOper {
2608
+						client.rplWhoReply(channel, member, rb)
2609
+					}
2606
 				}
2610
 				}
2607
 			}
2611
 			}
2608
 		}
2612
 		}

Loading…
Cancel
Save