3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-10 22:19:31 +01:00

tweaks to NAMES / WHO privacy

This commit is contained in:
Shivaram Lingamneni 2019-04-28 21:09:56 -04:00
parent 29fad23e5a
commit 74afeaed55
2 changed files with 11 additions and 6 deletions

View File

@ -336,13 +336,14 @@ func (channel *Channel) regenerateMembersCache() {
// Names sends the list of users joined to the channel to the given client. // Names sends the list of users joined to the channel to the given client.
func (channel *Channel) Names(client *Client, rb *ResponseBuffer) { func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
isJoined := channel.hasClient(client) isJoined := channel.hasClient(client)
isOper := client.HasMode(modes.Operator)
isMultiPrefix := rb.session.capabilities.Has(caps.MultiPrefix) isMultiPrefix := rb.session.capabilities.Has(caps.MultiPrefix)
isUserhostInNames := rb.session.capabilities.Has(caps.UserhostInNames) isUserhostInNames := rb.session.capabilities.Has(caps.UserhostInNames)
maxNamLen := 480 - len(client.server.name) - len(client.Nick()) maxNamLen := 480 - len(client.server.name) - len(client.Nick())
var namesLines []string var namesLines []string
var buffer bytes.Buffer var buffer bytes.Buffer
if isJoined || !channel.flags.HasMode(modes.Secret) { if isJoined || !channel.flags.HasMode(modes.Secret) || isOper {
for _, target := range channel.Members() { for _, target := range channel.Members() {
var nick string var nick string
if isUserhostInNames { if isUserhostInNames {
@ -356,7 +357,7 @@ func (channel *Channel) Names(client *Client, rb *ResponseBuffer) {
if modeSet == nil { if modeSet == nil {
continue continue
} }
if !isJoined && target.flags.HasMode(modes.Invisible) { if !isJoined && target.flags.HasMode(modes.Invisible) && !isOper {
continue continue
} }
prefix := modeSet.Prefixes(isMultiPrefix) prefix := modeSet.Prefixes(isMultiPrefix)

View File

@ -2595,17 +2595,21 @@ func whoHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo
// operatorOnly = true // operatorOnly = true
//} //}
isOper := client.HasMode(modes.Operator)
if mask[0] == '#' { if mask[0] == '#' {
// TODO implement wildcard matching // TODO implement wildcard matching
//TODO(dan): ^ only for opers //TODO(dan): ^ only for opers
channel := server.channels.Get(mask) channel := server.channels.Get(mask)
if channel != nil && channel.hasClient(client) { if channel != nil {
isJoined := channel.hasClient(client)
if !channel.flags.HasMode(modes.Secret) || isJoined || isOper {
for _, member := range channel.Members() { for _, member := range channel.Members() {
if !member.HasMode(modes.Invisible) { if !member.HasMode(modes.Invisible) || isJoined || isOper {
client.rplWhoReply(channel, member, rb) client.rplWhoReply(channel, member, rb)
} }
} }
} }
}
} else { } else {
for mclient := range server.clients.FindAll(mask) { for mclient := range server.clients.FindAll(mask) {
client.rplWhoReply(nil, mclient, rb) client.rplWhoReply(nil, mclient, rb)