# HG changeset patch # User Kim Alvefur # Date 1430652075 -7200 # Node ID 6b2122630b925b64ae5dab3cf75e8b41029ac23e # Parent d20cfc5ba827d7633b454c5941153115dd79e2ec mod_mam: Support the mandatory 'complete' attribute by requesting one extra item from storage diff -r d20cfc5ba827 -r 6b2122630b92 mod_mam/mod_mam.lua --- a/mod_mam/mod_mam.lua Sun May 03 13:20:04 2015 +0200 +++ b/mod_mam/mod_mam.lua Sun May 03 13:21:15 2015 +0200 @@ -124,7 +124,7 @@ local data, err = archive:find(origin.username, { start = qstart; ["end"] = qend; -- Time range with = qwith; - limit = qmax; + limit = qmax + 1; before = before; after = after; reverse = reverse; total = true; @@ -141,7 +141,14 @@ -- Wrap it in stuff and deliver local fwd_st, first, last; + local count = 0; + local complete = "true"; for id, item, when in data do + count = count + 1; + if count > qmax then + complete = nil; + break; + end fwd_st = st.message(msg_reply_attr) :tag("result", { xmlns = xmlns_mam, queryid = qid, id = id }) :tag("forwarded", { xmlns = xmlns_forward }) @@ -163,7 +170,7 @@ if reverse then first, last = last, first; end origin.send(st.message(msg_reply_attr) - :tag("fin", { xmlns = xmlns_mam, queryid = qid }) + :tag("fin", { xmlns = xmlns_mam, queryid = qid, complete = complete }) :add_child(rsm.generate { first = first, last = last, count = count })); return true;