From 9e2ef3905c6fe1325002959362aa0430916931e1 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(-) (limited to 'plugins/mod_muc_mam.lua') 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