Browse Source

fix #2133

Don't record NICK and QUIT in history for invisible auditorium members
pull/2137/head
Shivaram Lingamneni 3 months ago
parent
commit
5a348fe6f5
3 changed files with 25 additions and 4 deletions
  1. 16
    0
      irc/channel.go
  2. 6
    3
      irc/client.go
  3. 3
    1
      irc/nickname.go

+ 16
- 0
irc/channel.go View File

1622
 	return
1622
 	return
1623
 }
1623
 }
1624
 
1624
 
1625
+// returns whether the client is visible to unprivileged users in the channel
1626
+// (i.e., respecting auditorium mode)
1627
+func (channel *Channel) clientIsVisible(client *Client) bool {
1628
+	channel.stateMutex.RLock()
1629
+	defer channel.stateMutex.RUnlock()
1630
+
1631
+	clientData, found := channel.members[client]
1632
+	if !found {
1633
+		return false
1634
+	}
1635
+	if !channel.flags.HasMode(modes.Auditorium) {
1636
+		return true
1637
+	}
1638
+	return clientData.modes.HighestChannelUserMode() != modes.Mode(0)
1639
+}
1640
+
1625
 // data for RPL_LIST
1641
 // data for RPL_LIST
1626
 func (channel *Channel) listData() (memberCount int, name, topic string) {
1642
 func (channel *Channel) listData() (memberCount int, name, topic string) {
1627
 	channel.stateMutex.RLock()
1643
 	channel.stateMutex.RLock()

+ 6
- 3
irc/client.go View File

1297
 	}
1297
 	}
1298
 
1298
 
1299
 	var quitItem history.Item
1299
 	var quitItem history.Item
1300
-	var channels []*Channel
1300
+	var quitHistoryChannels []*Channel
1301
 	// use a defer here to avoid writing to mysql while holding the destroy semaphore:
1301
 	// use a defer here to avoid writing to mysql while holding the destroy semaphore:
1302
 	defer func() {
1302
 	defer func() {
1303
-		for _, channel := range channels {
1303
+		for _, channel := range quitHistoryChannels {
1304
 			channel.AddHistoryItem(quitItem, details.account)
1304
 			channel.AddHistoryItem(quitItem, details.account)
1305
 		}
1305
 		}
1306
 	}()
1306
 	}()
1322
 	// clean up channels
1322
 	// clean up channels
1323
 	// (note that if this is a reattach, client has no channels and therefore no friends)
1323
 	// (note that if this is a reattach, client has no channels and therefore no friends)
1324
 	friends := make(ClientSet)
1324
 	friends := make(ClientSet)
1325
-	channels = client.Channels()
1325
+	channels := client.Channels()
1326
 	for _, channel := range channels {
1326
 	for _, channel := range channels {
1327
+		if channel.clientIsVisible(client) {
1328
+			quitHistoryChannels = append(quitHistoryChannels, channel)
1329
+		}
1327
 		for _, member := range channel.auditoriumFriends(client) {
1330
 		for _, member := range channel.auditoriumFriends(client) {
1328
 			friends.Add(member)
1331
 			friends.Add(member)
1329
 		}
1332
 		}

+ 3
- 1
irc/nickname.go View File

120
 	}
120
 	}
121
 
121
 
122
 	for _, channel := range target.Channels() {
122
 	for _, channel := range target.Channels() {
123
-		channel.AddHistoryItem(histItem, details.account)
123
+		if channel.clientIsVisible(client) {
124
+			channel.AddHistoryItem(histItem, details.account)
125
+		}
124
 	}
126
 	}
125
 
127
 
126
 	newCfnick := target.NickCasefolded()
128
 	newCfnick := target.NickCasefolded()

Loading…
Cancel
Save