# HG changeset patch # User Kim Alvefur # Date 1524869068 -7200 # Node ID 79133eca065697626a31e4cced1a1b4a49758253 # Parent daa518a22c34d05a486329b44032806737687d9b mod_muc_mam: Tweak calculation of max history to retrieve diff -r daa518a22c34 -r 79133eca0656 plugins/mod_muc_mam.lua --- a/plugins/mod_muc_mam.lua Mon Apr 30 18:08:09 2018 +0100 +++ b/plugins/mod_muc_mam.lua Sat Apr 28 00:44:28 2018 +0200 @@ -241,14 +241,18 @@ 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