# HG changeset patch # User Kim Alvefur # Date 1339130660 -7200 # Node ID 0dda04d5eb84ea88373e876e31b7c6f60fd1fef8 # Parent 0c83cb47624634ad161156785374769d0a193010 plugins.archive: Treat query params correctly diff -r 0c83cb476246 -r 0dda04d5eb84 plugins/archive.lua --- a/plugins/archive.lua Mon May 28 17:32:38 2012 +0200 +++ b/plugins/archive.lua Fri Jun 08 06:44:20 2012 +0200 @@ -9,6 +9,8 @@ local xmlns_delay = "urn:xmpp:delay"; local uuid = require "util.uuid".generate; local parse_datetime = require "util.datetime".parse; +local datetime = require "util.datetime".datetime; +local tonumber = tonumber; function verse.plugins.archive(stream) function stream:query_archive(where, query_params, callback) @@ -16,13 +18,17 @@ local query_st = st.iq{ type="get", to = where } :tag("query", { xmlns = xmlns_mam, queryid = queryid }); - local params = { "with", "start", "end" }; - local query_params = query_params or {}; - for i=1,#params do - local k = params[i]; - if query_params[k] then - query_st:tag(k):text(query_params[k]):up(); - end + local qwith = query_params["with"]; + if qwith then + query_st:tag("with"):text(qwith):up(); + end + + local qstart, qend = tonumber(query_params["start"]), tonumber(query_params["end"]); + if qstart then + query_st:tag("start"):text(datetime(qstart)):up(); + end + if qend then + query_st:tag("end"):text(datetime(qend)):up(); end local results = {};