3
0
mirror of https://github.com/ergochat/ergo.git synced 2024-11-29 23:49:25 +01:00

Merge pull request #538 from slingamn/issue537.1

fix #537
This commit is contained in:
Daniel Oaks 2019-06-10 01:14:32 +10:00 committed by GitHub
commit 655f1f6f54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 28 additions and 12 deletions

View File

@ -65,10 +65,17 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
return errNoSuchChannel return errNoSuchChannel
} }
channel := func() *Channel {
cm.Lock() cm.Lock()
defer cm.Unlock()
entry := cm.chans[casefoldedName] entry := cm.chans[casefoldedName]
if entry == nil { if entry == nil {
registered := cm.registeredChannels[casefoldedName] registered := cm.registeredChannels[casefoldedName]
// enforce OpOnlyCreation
if !registered && server.Config().Channels.OpOnlyCreation && !client.HasRoleCapabs("chanreg") {
return nil
}
entry = &channelManagerEntry{ entry = &channelManagerEntry{
channel: NewChannel(server, name, registered), channel: NewChannel(server, name, registered),
pendingJoins: 0, pendingJoins: 0,
@ -76,8 +83,12 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
cm.chans[casefoldedName] = entry cm.chans[casefoldedName] = entry
} }
entry.pendingJoins += 1 entry.pendingJoins += 1
channel := entry.channel return entry.channel
cm.Unlock() }()
if channel == nil {
return errNoSuchChannel
}
channel.EnsureLoaded() channel.EnsureLoaded()
channel.Join(client, key, isSajoin, rb) channel.Join(client, key, isSajoin, rb)

View File

@ -321,6 +321,7 @@ type Config struct {
DefaultModes *string `yaml:"default-modes"` DefaultModes *string `yaml:"default-modes"`
defaultModes modes.Modes defaultModes modes.Modes
MaxChannelsPerClient int `yaml:"max-channels-per-client"` MaxChannelsPerClient int `yaml:"max-channels-per-client"`
OpOnlyCreation bool `yaml:"operator-only-creation"`
Registration ChannelRegistrationConfig Registration ChannelRegistrationConfig
} }

View File

@ -368,6 +368,10 @@ channels:
# how many channels can a client be in at once? # how many channels can a client be in at once?
max-channels-per-client: 100 max-channels-per-client: 100
# if this is true, new channels can only be created by operators with the
# `chanreg` operator capability
operator-only-creation: false
# channel registration - requires an account # channel registration - requires an account
registration: registration:
# can users register new channels? # can users register new channels?