mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
names should respect invisibility
This commit is contained in:
parent
30f6e11698
commit
d6c970f521
@ -335,12 +335,14 @@ func (channel *Channel) regenerateMembersCache() {
|
||||
|
||||
// Names sends the list of users joined to the channel to the given client.
|
||||
func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
|
||||
isJoined := channel.hasClient(client)
|
||||
isMultiPrefix := rb.session.capabilities.Has(caps.MultiPrefix)
|
||||
isUserhostInNames := rb.session.capabilities.Has(caps.UserhostInNames)
|
||||
|
||||
maxNamLen := 480 - len(client.server.name) - len(client.Nick())
|
||||
var namesLines []string
|
||||
var buffer bytes.Buffer
|
||||
if isJoined || !channel.flags.HasMode(modes.Secret) {
|
||||
for _, target := range channel.Members() {
|
||||
var nick string
|
||||
if isUserhostInNames {
|
||||
@ -349,12 +351,15 @@ func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
|
||||
nick = target.Nick()
|
||||
}
|
||||
channel.stateMutex.RLock()
|
||||
modes := channel.members[target]
|
||||
modeSet := channel.members[target]
|
||||
channel.stateMutex.RUnlock()
|
||||
if modes == nil {
|
||||
if modeSet == nil {
|
||||
continue
|
||||
}
|
||||
prefix := modes.Prefixes(isMultiPrefix)
|
||||
if !isJoined && target.flags.HasMode(modes.Invisible) {
|
||||
continue
|
||||
}
|
||||
prefix := modeSet.Prefixes(isMultiPrefix)
|
||||
if buffer.Len()+len(nick)+len(prefix)+1 > maxNamLen {
|
||||
namesLines = append(namesLines, buffer.String())
|
||||
buffer.Reset()
|
||||
@ -368,6 +373,7 @@ func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
|
||||
if buffer.Len() > 0 {
|
||||
namesLines = append(namesLines, buffer.String())
|
||||
}
|
||||
}
|
||||
|
||||
for _, line := range namesLines {
|
||||
if buffer.Len() > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user