3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-13 07:29:30 +01:00

modes: use secret instead of private, it's the standard these days. fix secret channel hiding in whois

This commit is contained in:
Daniel Oaks 2016-04-14 22:33:38 +10:00
parent a715882a75
commit 8b79662f1a
4 changed files with 15 additions and 12 deletions

View File

@ -367,7 +367,7 @@ func (channel *Channel) applyMode(client *Client, change *ChannelModeChange) boo
return channel.applyModeMask(client, change.mode, change.op,
NewName(change.arg))
case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Persistent, Private:
case InviteOnly, Moderated, NoOutside, OpOnlyTopic, Persistent, Secret:
return channel.applyModeFlag(client, change.mode, change.op)
case Key:

View File

@ -82,9 +82,8 @@ const (
NoOutside ChannelMode = 'n' // flag
OpOnlyTopic ChannelMode = 't' // flag
Persistent ChannelMode = 'P' // flag
Private ChannelMode = 'p' // flag
ReOp ChannelMode = 'r' // flag
Secret ChannelMode = 's' // flag, deprecated
Secret ChannelMode = 's' // flag
Theater ChannelMode = 'T' // flag, nonstandard
UserLimit ChannelMode = 'l' // flag arg
)
@ -92,7 +91,7 @@ const (
var (
SupportedChannelModes = ChannelModes{
BanMask, ExceptMask, InviteMask, InviteOnly, Key, NoOutside,
OpOnlyTopic, Persistent, Private, Theater, UserLimit,
OpOnlyTopic, Persistent, Secret, Theater, UserLimit,
}
// ChannelPrivModes holds the list of modes that are privileged, ie founder/op/halfop, in order.

View File

@ -407,7 +407,7 @@ func (target *Client) RplNamReply(channel *Channel) {
}
func (target *Client) RplWhoisChannels(client *Client) {
target.MultilineReply(client.WhoisChannelsNames(target.capabilities[MultiPrefix]), RPL_WHOISCHANNELS,
target.MultilineReply(client.WhoisChannelsNames(target), RPL_WHOISCHANNELS,
"%s :%s", client.Nick())
}

View File

@ -501,13 +501,17 @@ func (msg *PrivMsgCommand) HandleServer(server *Server) {
}
}
func (client *Client) WhoisChannelsNames(isMultiPrefix bool) []string {
chstrs := make([]string, len(client.channels))
func (client *Client) WhoisChannelsNames(target *Client) []string {
isMultiPrefix := target.capabilities[MultiPrefix]
var chstrs []string
index := 0
//TODO(dan): handle secret (+s) channels here properly?
for channel := range client.channels {
chstrs[index] = channel.members[client].Prefixes(isMultiPrefix) + channel.name.String()
index += 1
// channel is secret and the target can't see it
if !target.flags[Operator] && channel.flags[Secret] && !channel.members.Has(target) {
continue
}
chstrs = append(chstrs, channel.members[client].Prefixes(isMultiPrefix)+channel.name.String())
index++
}
return chstrs
}
@ -689,7 +693,7 @@ func (msg *ListCommand) HandleServer(server *Server) {
if len(msg.channels) == 0 {
for _, channel := range server.channels {
if !client.flags[Operator] && channel.flags[Private] {
if !client.flags[Operator] && channel.flags[Secret] {
continue
}
client.RplList(channel)
@ -697,7 +701,7 @@ func (msg *ListCommand) HandleServer(server *Server) {
} else {
for _, chname := range msg.channels {
channel := server.channels.Get(chname)
if channel == nil || (!client.flags[Operator] && channel.flags[Private]) {
if channel == nil || (!client.flags[Operator] && channel.flags[Secret]) {
client.ErrNoSuchChannel(chname)
continue
}