diff --git a/irc/config.go b/irc/config.go index 634ac5f5..fd997512 100644 --- a/irc/config.go +++ b/irc/config.go @@ -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) diff --git a/irc/handlers.go b/irc/handlers.go index 3ffc505c..b74800f0 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -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]) diff --git a/irc/server.go b/irc/server.go index d1cf736e..3c763593 100644 --- a/irc/server.go +++ b/irc/server.go @@ -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 }