Skip to content

Commit 8d08286

Browse files
authored
fix #2133 (#2137)
* fix #2133 Don't record NICK and QUIT in history for invisible auditorium members
1 parent 681e8b1 commit 8d08286

3 files changed

Lines changed: 29 additions & 4 deletions

File tree

irc/channel.go

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1622,6 +1622,26 @@ func (channel *Channel) auditoriumFriends(client *Client) (friends []*Client) {
16221622
return
16231623
}
16241624

1625+
// returns whether the client is visible to unprivileged users in the channel
1626+
// (i.e., respecting auditorium mode). note that this assumes that the client
1627+
// is a member; if the client is not, it may return true anyway
1628+
func (channel *Channel) memberIsVisible(client *Client) bool {
1629+
// fast path, we assume they're a member so if this isn't an auditorium,
1630+
// they're visible:
1631+
if !channel.flags.HasMode(modes.Auditorium) {
1632+
return true
1633+
}
1634+
1635+
channel.stateMutex.RLock()
1636+
defer channel.stateMutex.RUnlock()
1637+
1638+
clientData, found := channel.members[client]
1639+
if !found {
1640+
return false
1641+
}
1642+
return clientData.modes.HighestChannelUserMode() != modes.Mode(0)
1643+
}
1644+
16251645
// data for RPL_LIST
16261646
func (channel *Channel) listData() (memberCount int, name, topic string) {
16271647
channel.stateMutex.RLock()

irc/client.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1297,10 +1297,10 @@ func (client *Client) destroy(session *Session) {
12971297
}
12981298

12991299
var quitItem history.Item
1300-
var channels []*Channel
1300+
var quitHistoryChannels []*Channel
13011301
// use a defer here to avoid writing to mysql while holding the destroy semaphore:
13021302
defer func() {
1303-
for _, channel := range channels {
1303+
for _, channel := range quitHistoryChannels {
13041304
channel.AddHistoryItem(quitItem, details.account)
13051305
}
13061306
}()
@@ -1322,8 +1322,11 @@ func (client *Client) destroy(session *Session) {
13221322
// clean up channels
13231323
// (note that if this is a reattach, client has no channels and therefore no friends)
13241324
friends := make(ClientSet)
1325-
channels = client.Channels()
1325+
channels := client.Channels()
13261326
for _, channel := range channels {
1327+
if channel.memberIsVisible(client) {
1328+
quitHistoryChannels = append(quitHistoryChannels, channel)
1329+
}
13271330
for _, member := range channel.auditoriumFriends(client) {
13281331
friends.Add(member)
13291332
}

irc/nickname.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ func performNickChange(server *Server, client *Client, target *Client, session *
120120
}
121121

122122
for _, channel := range target.Channels() {
123-
channel.AddHistoryItem(histItem, details.account)
123+
if channel.memberIsVisible(client) {
124+
channel.AddHistoryItem(histItem, details.account)
125+
}
124126
}
125127

126128
newCfnick := target.NickCasefolded()

0 commit comments

Comments
 (0)