mirror of
https://github.com/ergochat/ergo.git
synced 2024-12-22 10:42:52 +01:00
fix #537
This commit is contained in:
parent
a521be8119
commit
3b71be3bf0
@ -65,19 +65,30 @@ func (cm *ChannelManager) Join(client *Client, name string, key string, isSajoin
|
|||||||
return errNoSuchChannel
|
return errNoSuchChannel
|
||||||
}
|
}
|
||||||
|
|
||||||
cm.Lock()
|
channel := func() *Channel {
|
||||||
entry := cm.chans[casefoldedName]
|
cm.Lock()
|
||||||
if entry == nil {
|
defer cm.Unlock()
|
||||||
registered := cm.registeredChannels[casefoldedName]
|
|
||||||
entry = &channelManagerEntry{
|
entry := cm.chans[casefoldedName]
|
||||||
channel: NewChannel(server, name, registered),
|
if entry == nil {
|
||||||
pendingJoins: 0,
|
registered := cm.registeredChannels[casefoldedName]
|
||||||
|
// enforce OpOnlyCreation
|
||||||
|
if !registered && server.Config().Channels.OpOnlyCreation && !client.HasRoleCapabs("chanreg") {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
entry = &channelManagerEntry{
|
||||||
|
channel: NewChannel(server, name, registered),
|
||||||
|
pendingJoins: 0,
|
||||||
|
}
|
||||||
|
cm.chans[casefoldedName] = entry
|
||||||
}
|
}
|
||||||
cm.chans[casefoldedName] = entry
|
entry.pendingJoins += 1
|
||||||
|
return entry.channel
|
||||||
|
}()
|
||||||
|
|
||||||
|
if channel == nil {
|
||||||
|
return errNoSuchChannel
|
||||||
}
|
}
|
||||||
entry.pendingJoins += 1
|
|
||||||
channel := entry.channel
|
|
||||||
cm.Unlock()
|
|
||||||
|
|
||||||
channel.EnsureLoaded()
|
channel.EnsureLoaded()
|
||||||
channel.Join(client, key, isSajoin, rb)
|
channel.Join(client, key, isSajoin, rb)
|
||||||
|
@ -320,7 +320,8 @@ type Config struct {
|
|||||||
Channels struct {
|
Channels 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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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?
|
||||||
|
Loading…
Reference in New Issue
Block a user