Changeset

304:e09ae2395d41

squishy, plugins.archive: Fetch RSM lib from prosody-modules and use.
author Kim Alvefur <zash@zash.se>
date Fri, 08 Jun 2012 21:39:01 +0200
parents 303:0dda04d5eb84
children 305:4a0206505b9d
files plugins/archive.lua squishy
diffstat 2 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/archive.lua	Fri Jun 08 06:44:20 2012 +0200
+++ b/plugins/archive.lua	Fri Jun 08 21:39:01 2012 +0200
@@ -10,7 +10,9 @@
 local uuid = require "util.uuid".generate;
 local parse_datetime = require "util.datetime".parse;
 local datetime = require "util.datetime".datetime;
+local rsm = require "util.rsm";
 local tonumber = tonumber;
+local NULL = {};
 
 function verse.plugins.archive(stream)
 	function stream:query_archive(where, query_params, callback)
@@ -30,6 +32,11 @@
 		if qend then
 			query_st:tag("end"):text(datetime(qend)):up();
 		end
+		query_params["start"], query_params["end"], query_params["with"] = nil, nil, nil;
+
+		if next(query_params) then
+			query_st:add_child(rsm.generate(query_params));
+		end
 
 		local results = {};
 		local function handle_archived_message(message)
@@ -51,6 +58,8 @@
 		self:hook("message", handle_archived_message, 1);
 		self:send_iq(query_st, function(reply)
 			self:unhook("message", handle_archived_message);
+			local rset = reply.tags[1] and rsm.get(reply.tags[1]);
+			for k,v in pairs(rset or NULL) do results[k]=v; end
 			callback(reply.attr.type == "result" and #results, results);
 			return true
 		end);
--- a/squishy	Fri Jun 08 06:44:20 2012 +0200
+++ b/squishy	Fri Jun 08 21:39:01 2012 +0200
@@ -6,6 +6,8 @@
 Module "util.sha1"		"util/sha1.lua"
 Module "lib.adhoc"              "libs/adhoc.lib.lua"
 
+AutoFetchURL("https://prosody-modules.googlecode.com/hg/mod_mam/?");
+Module "util.rsm"       "rsm.lib.lua"
 -- Prosody libraries
 if not GetOption("prosody") then
 	AutoFetchURL "http://hg.prosody.im/0.9/raw-file/381e0b874e6d/?"