From de89c2de1119f9b82953690fada3d86464216dca Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Sat, 28 Apr 2018 00:44:28 +0200 Subject: mod_muc_mam: Tweak calculation of max history to retrieve --- plugins/mod_muc_mam.lua | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/mod_muc_mam.lua b/plugins/mod_muc_mam.lua index bf3cae45..de59641c 100644 --- a/plugins/mod_muc_mam.lua +++ b/plugins/mod_muc_mam.lua @@ -241,14 +241,18 @@ module:hook("muc-get-history", function (event) local room = event.room; if not archiving_enabled(room) then return end local room_jid = room.jid; - local maxstanzas = event.maxstanzas or math.huge; + local maxstanzas = event.maxstanzas; local maxchars = event.maxchars; local since = event.since; local to = event.to; + if not maxstanzas or maxstanzas > get_historylength(room) then + maxstanzas = get_historylength(room); + end + -- Load all the data! local query = { - limit = math.min(maxstanzas, get_historylength(room)); + limit = maxstanzas; start = since; reverse = true; with = "message