mirror of
https://github.com/ergochat/ergo.git
synced 2025-12-16 21:07:39 +01:00
Fix inconsistent behavior when history.enabled is set but history.chathistory-maxmessages is not
This commit is contained in:
parent
aef5d77b3b
commit
fdd261a1e6
@ -1611,7 +1611,7 @@ func LoadConfig(filename string) (config *Config, err error) {
|
||||
// in the current implementation, we disable history by creating a history buffer
|
||||
// with zero capacity. but the `enabled` config option MUST be respected regardless
|
||||
// of this detail
|
||||
if !config.History.Enabled {
|
||||
if !config.History.Enabled || config.History.ChathistoryMax == 0 {
|
||||
config.History.ChannelLength = 0
|
||||
config.History.ClientLength = 0
|
||||
config.Server.supportedCaps.Disable(caps.Chathistory)
|
||||
|
||||
@ -700,11 +700,13 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.Message, rb *
|
||||
var channel *Channel
|
||||
var sequence history.Sequence
|
||||
var err error
|
||||
var listTargets bool
|
||||
var disabled, listTargets bool
|
||||
var targets []history.TargetListing
|
||||
defer func() {
|
||||
// errors are sent either without a batch, or in a draft/labeled-response batch as usual
|
||||
if err == utils.ErrInvalidParams {
|
||||
if disabled {
|
||||
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "MESSAGE_ERROR", msg.Params[0], client.t("That feature is disabled"))
|
||||
} else if err == utils.ErrInvalidParams {
|
||||
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "INVALID_PARAMS", msg.Params[0], client.t("Invalid parameters"))
|
||||
} else if !listTargets && sequence == nil {
|
||||
rb.Add(nil, server.name, "FAIL", "CHATHISTORY", "INVALID_TARGET", msg.Params[0], utils.SafeErrorParam(target), client.t("Messages could not be retrieved"))
|
||||
@ -730,7 +732,8 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.Message, rb *
|
||||
|
||||
config := server.Config()
|
||||
maxChathistoryLimit := config.History.ChathistoryMax
|
||||
if maxChathistoryLimit == 0 {
|
||||
if !config.History.Enabled || maxChathistoryLimit == 0 {
|
||||
disabled = true
|
||||
return
|
||||
}
|
||||
preposition := strings.ToLower(msg.Params[0])
|
||||
|
||||
@ -908,6 +908,9 @@ func (server *Server) applyConfig(config *Config) (err error) {
|
||||
if config.Accounts.RequireSasl.Enabled && config.Accounts.Registration.Enabled {
|
||||
server.logger.Warning("server", "Warning: although require-sasl is enabled, users can still register accounts. If your server is not intended to be public, you must set accounts.registration.enabled to false.")
|
||||
}
|
||||
if config.History.Enabled && config.History.ChathistoryMax == 0 {
|
||||
server.logger.Warning("server", "Warning: for history to work correctly, you must set history.chathistory-maxmessages (see default.yaml for a recommendation).")
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user