mirror of
https://github.com/ergochat/ergo.git
synced 2024-11-10 22:19:31 +01:00
fix #685
This commit is contained in:
parent
9559ea6764
commit
bd45c346dc
@ -293,16 +293,17 @@ func csOpHandler(server *Server, client *Client, command string, params []string
|
|||||||
}
|
}
|
||||||
|
|
||||||
func csRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
func csRegisterHandler(server *Server, client *Client, command string, params []string, rb *ResponseBuffer) {
|
||||||
channelName := params[0]
|
if server.Config().Channels.Registration.OperatorOnly && !client.HasRoleCapabs("chanreg") {
|
||||||
|
csNotice(rb, client.t("Channel registration is restricted to server operators"))
|
||||||
channelKey, err := CasefoldChannel(channelName)
|
|
||||||
if err != nil {
|
|
||||||
csNotice(rb, client.t("Channel name is not valid"))
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
channelName := params[0]
|
||||||
channelInfo := server.channels.Get(channelKey)
|
channelInfo := server.channels.Get(channelName)
|
||||||
if channelInfo == nil || !channelInfo.ClientIsAtLeast(client, modes.ChannelOperator) {
|
if channelInfo == nil {
|
||||||
|
csNotice(rb, client.t("No such channel"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if !channelInfo.ClientIsAtLeast(client, modes.ChannelOperator) {
|
||||||
csNotice(rb, client.t("You must be an oper on the channel to register it"))
|
csNotice(rb, client.t("You must be an oper on the channel to register it"))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -313,7 +314,7 @@ func csRegisterHandler(server *Server, client *Client, command string, params []
|
|||||||
}
|
}
|
||||||
|
|
||||||
// this provides the synchronization that allows exactly one registration of the channel:
|
// this provides the synchronization that allows exactly one registration of the channel:
|
||||||
err = server.channels.SetRegistered(channelKey, account)
|
err := server.channels.SetRegistered(channelName, account)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
csNotice(rb, err.Error())
|
csNotice(rb, err.Error())
|
||||||
return
|
return
|
||||||
|
@ -385,12 +385,6 @@ func (cm *Casemapping) UnmarshalYAML(unmarshal func(interface{}) error) (err err
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ChannelRegistrationConfig controls channel registration.
|
|
||||||
type ChannelRegistrationConfig struct {
|
|
||||||
Enabled bool
|
|
||||||
MaxChannelsPerAccount int `yaml:"max-channels-per-account"`
|
|
||||||
}
|
|
||||||
|
|
||||||
// OperClassConfig defines a specific operator class.
|
// OperClassConfig defines a specific operator class.
|
||||||
type OperClassConfig struct {
|
type OperClassConfig struct {
|
||||||
Title string
|
Title string
|
||||||
@ -534,7 +528,11 @@ type Config struct {
|
|||||||
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"`
|
OpOnlyCreation bool `yaml:"operator-only-creation"`
|
||||||
Registration ChannelRegistrationConfig
|
Registration struct {
|
||||||
|
Enabled bool
|
||||||
|
OperatorOnly bool `yaml:"operator-only"`
|
||||||
|
MaxChannelsPerAccount int `yaml:"max-channels-per-account"`
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`
|
OperClasses map[string]*OperClassConfig `yaml:"oper-classes"`
|
||||||
|
@ -472,6 +472,10 @@ channels:
|
|||||||
# can users register new channels?
|
# can users register new channels?
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
# restrict new channel registrations to operators only?
|
||||||
|
# (operators can then transfer channels to regular users using /CS TRANSFER)
|
||||||
|
operator-only: false
|
||||||
|
|
||||||
# how many channels can each account register?
|
# how many channels can each account register?
|
||||||
max-channels-per-account: 15
|
max-channels-per-account: 15
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user