# HG changeset patch
# User Kim Alvefur <zash@zash.se>
# Date 1528586405 -7200
# Node ID f15e35458ecc54f05d57aea977da8c65804e7d63
# Parent  c5d5dfaa8d38f779e838eade99c7fb0407d8c1e6# Parent  65d1a80d356592b57c5b4122f62f71a1df2037b7
Merge 0.10->trunk

diff -r c5d5dfaa8d38 -r f15e35458ecc plugins/mod_mam/mod_mam.lua
--- a/plugins/mod_mam/mod_mam.lua	Sat Jun 09 15:30:26 2018 +0200
+++ b/plugins/mod_mam/mod_mam.lua	Sun Jun 10 01:20:05 2018 +0200
@@ -145,7 +145,7 @@
 	local data, err = archive:find(origin.username, {
 		start = qstart; ["end"] = qend; -- Time range
 		with = qwith;
-		limit = qmax + 1;
+		limit = qmax == 0 and 0 or qmax + 1;
 		before = before; after = after;
 		reverse = reverse;
 		total = use_total or qmax == 0;
@@ -168,6 +168,8 @@
 	for id, item, when in data do
 		count = count + 1;
 		if count > qmax then
+			-- We requested qmax+1 items. If that many items are retrieved then
+			-- there are more results to page through, so:
 			complete = nil;
 			break;
 		end