diff options
author | Kim Alvefur <zash@zash.se> | 2018-04-28 00:44:28 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2018-04-28 00:44:28 +0200 |
commit | 9e2ef3905c6fe1325002959362aa0430916931e1 (patch) | |
tree | 367c15de5b9b794382d6a3cfc18f0c39aa1e1390 | |
parent | 0b917d28da4f9cf06a8eeadcf077af4598fbce86 (diff) | |
download | prosody-9e2ef3905c6fe1325002959362aa0430916931e1.tar.gz prosody-9e2ef3905c6fe1325002959362aa0430916931e1.zip |
mod_muc_mam: Tweak calculation of max history to retrieve
-rw-r--r-- | plugins/mod_muc_mam.lua | 8 |
1 files 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<groupchat"; |