Software /
code /
prosody-modules
Diff
mod_mam_muc/mod_mam_muc.lua @ 2718:02d688ba7739
mod_mam_muc: Make calculation of max history length more like in mod_muc
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 23 Jun 2017 13:51:23 +0200 |
parent | 2716:02a7f9fe44fa |
child | 2719:7568157bf998 |
line wrap: on
line diff
--- a/mod_mam_muc/mod_mam_muc.lua Thu May 25 16:47:29 2017 +0200 +++ b/mod_mam_muc/mod_mam_muc.lua Fri Jun 23 13:51:23 2017 +0200 @@ -40,8 +40,13 @@ local time_now = os.time; local m_min = math.min; local timestamp, timestamp_parse = require "util.datetime".datetime, require "util.datetime".parse; -local max_history_length = module:get_option_number("max_history_messages", 1000); -local default_max_items, max_max_items = 20, module:get_option_number("max_archive_query_results", max_history_length); + +local default_history_length = 20; +local max_history_length = module:get_option_number("max_history_messages", math.huge); + +local function get_historylength(room) + return math.min(room._data.history_length or default_history_length, max_history_length); +end local log_all_rooms = module:get_option_boolean("muc_log_all_rooms", false); local log_by_default = module:get_option_boolean("muc_log_by_default", true); @@ -200,7 +205,7 @@ -- RSM stuff local qset = rsm.get(query); - local qmax = m_min(qset and qset.max or default_max_items, max_max_items); + local qmax = m_min(qset and qset.max or 20, 20); local reverse = qset and qset.before or false; local before, after = qset and qset.before, qset and qset.after; @@ -285,7 +290,7 @@ -- Load all the data! local query = { - limit = m_min(maxstanzas or 20, max_history_length); + limit = math.min(maxstanzas, get_historylength(room)); start = since; reverse = true; with = "message<groupchat";