mod_muc_mam: Tweak calculation of max history to retrieve
authorKim Alvefur <zash@zash.se>
Sat, 28 Apr 2018 00:44:28 +0200
changeset 8786 79133eca0656
parent 8785 daa518a22c34
child 8787 64b78e3deb96
mod_muc_mam: Tweak calculation of max history to retrieve
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<groupchat";