diff --git a/irc/config.go b/irc/config.go index bc3e4d76..dcc07f6b 100644 --- a/irc/config.go +++ b/irc/config.go @@ -213,7 +213,6 @@ type Limits struct { NickLen int `yaml:"nicklen"` TopicLen int `yaml:"topiclen"` WhowasEntries int `yaml:"whowas-entries"` - ChathistoryMax int `yaml:"chathistory-maxmessages"` } // STSConfig controls the STS configuration/ @@ -316,6 +315,7 @@ type Config struct { ChannelLength int `yaml:"channel-length"` ClientLength int `yaml:"client-length"` AutoreplayOnJoin int `yaml:"autoreplay-on-join"` + ChathistoryMax int `yaml:"chathistory-maxmessages"` } Filename string diff --git a/irc/handlers.go b/irc/handlers.go index 2ef3f4e4..84e080af 100644 --- a/irc/handlers.go +++ b/irc/handlers.go @@ -531,6 +531,7 @@ func capHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *Respo // CHATHISTORY BETWEEN [] // e.g., CHATHISTORY #ircv3 BETWEEN timestamp=YYYY-MM-DDThh:mm:ss.sssZ timestamp=YYYY-MM-DDThh:mm:ss.sssZ + 100 func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) (exiting bool) { + config := server.Config() // batch type is chathistory; send an empty batch if necessary rb.InitializeBatch("chathistory", true) @@ -595,7 +596,7 @@ func chathistoryHandler(server *Server, client *Client, msg ircmsg.IrcMessage, r return } - maxChathistoryLimit := server.Config().Limits.ChathistoryMax + maxChathistoryLimit := config.History.ChathistoryMax if maxChathistoryLimit == 0 { return } @@ -1008,6 +1009,7 @@ Get an explanation of , or "index" for a list of help topics.`), rb) // e.g., HISTORY #ubuntu 10 // HISTORY me 15 func historyHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *ResponseBuffer) bool { + config := server.Config() target := msg.Params[0] var hist *history.Buffer channel := server.channels.Get(target) @@ -1024,7 +1026,7 @@ func historyHandler(server *Server, client *Client, msg ircmsg.IrcMessage, rb *R } limit := 10 - maxChathistoryLimit := server.Config().Limits.ChathistoryMax + maxChathistoryLimit := config.History.ChathistoryMax if len(msg.Params) > 1 { providedLimit, err := strconv.Atoi(msg.Params[1]) if providedLimit > maxChathistoryLimit { diff --git a/irc/server.go b/irc/server.go index 259b308b..0ae58875 100644 --- a/irc/server.go +++ b/irc/server.go @@ -157,8 +157,8 @@ func (server *Server) setISupport() (err error) { isupport.Add("AWAYLEN", strconv.Itoa(config.Limits.AwayLen)) isupport.Add("CASEMAPPING", "ascii") isupport.Add("CHANMODES", strings.Join([]string{modes.Modes{modes.BanMask, modes.ExceptMask, modes.InviteMask}.String(), "", modes.Modes{modes.UserLimit, modes.Key}.String(), modes.Modes{modes.InviteOnly, modes.Moderated, modes.NoOutside, modes.OpOnlyTopic, modes.ChanRoleplaying, modes.Secret}.String()}, ",")) - if config.History.Enabled && config.Limits.ChathistoryMax > 0 { - isupport.Add("CHATHISTORY", strconv.Itoa(config.Limits.ChathistoryMax)) + if config.History.Enabled && config.History.ChathistoryMax > 0 { + isupport.Add("CHATHISTORY", strconv.Itoa(config.History.ChathistoryMax)) } isupport.Add("CHANNELLEN", strconv.Itoa(config.Limits.ChannelLen)) isupport.Add("CHANTYPES", "#") diff --git a/oragono.yaml b/oragono.yaml index bfd955c1..49aaad86 100644 --- a/oragono.yaml +++ b/oragono.yaml @@ -439,10 +439,6 @@ limits: # maximum length of channel lists (beI modes) chan-list-modes: 60 - # maximum number of CHATHISTORY messages that can be - # requested at once (0 disables support for CHATHISTORY) - chathistory-maxmessages: 100 - # maximum length of IRC lines # this should generally be 1024-2048, and will only apply when negotiated by clients linelen: @@ -484,3 +480,7 @@ history: # number of messages to automatically play back on channel join (0 to disable): autoreplay-on-join: 0 + + # maximum number of CHATHISTORY messages that can be + # requested at once (0 disables support for CHATHISTORY) + chathistory-maxmessages: 100