3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-22 11:59:40 +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, return channel.applyModeMask(client, change.mode, change.op,
NewName(change.arg)) 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) return channel.applyModeFlag(client, change.mode, change.op)
case Key: case Key:

View File

@ -82,9 +82,8 @@ const (
NoOutside ChannelMode = 'n' // flag NoOutside ChannelMode = 'n' // flag
OpOnlyTopic ChannelMode = 't' // flag OpOnlyTopic ChannelMode = 't' // flag
Persistent ChannelMode = 'P' // flag Persistent ChannelMode = 'P' // flag
Private ChannelMode = 'p' // flag
ReOp ChannelMode = 'r' // flag ReOp ChannelMode = 'r' // flag
Secret ChannelMode = 's' // flag, deprecated Secret ChannelMode = 's' // flag
Theater ChannelMode = 'T' // flag, nonstandard Theater ChannelMode = 'T' // flag, nonstandard
UserLimit ChannelMode = 'l' // flag arg UserLimit ChannelMode = 'l' // flag arg
) )
@ -92,7 +91,7 @@ const (
var ( var (
SupportedChannelModes = ChannelModes{ SupportedChannelModes = ChannelModes{
BanMask, ExceptMask, InviteMask, InviteOnly, Key, NoOutside, 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. // 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) { 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()) "%s :%s", client.Nick())
} }

View File

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