Software /
code /
verse
Comparison
plugins/archive.lua @ 295:5f7203bf1dae
plugins.archive: Move namespaces to the top
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 20 Apr 2012 01:39:31 +0200 |
parent | 294:ac039aa3a4ef |
child | 296:78ddfd30c74e |
comparison
equal
deleted
inserted
replaced
294:ac039aa3a4ef | 295:5f7203bf1dae |
---|---|
3 -- (ie not XEP-0136) | 3 -- (ie not XEP-0136) |
4 | 4 |
5 local verse = require "verse"; | 5 local verse = require "verse"; |
6 local st = require "util.stanza"; | 6 local st = require "util.stanza"; |
7 local xmlns_mam = "urn:xmpp:mam:tmp" | 7 local xmlns_mam = "urn:xmpp:mam:tmp" |
8 local xmlns_forward = "urn:xmpp:forward:0"; | |
9 local xmlns_delay = "urn:xmpp:delay"; | |
8 local uuid = require "util.uuid".generate; | 10 local uuid = require "util.uuid".generate; |
9 | 11 |
10 function verse.plugins.archive(stream) | 12 function verse.plugins.archive(stream) |
11 function stream:query_archive(where, query_params, callback) | 13 function stream:query_archive(where, query_params, callback) |
12 local queryid = uuid(); | 14 local queryid = uuid(); |
24 | 26 |
25 local results = {}; | 27 local results = {}; |
26 local function handle_archived_message(message) | 28 local function handle_archived_message(message) |
27 local result_tag = message:get_child("result", xmlns_mam); | 29 local result_tag = message:get_child("result", xmlns_mam); |
28 if result_tag and result_tag.attr.queryid == queryid then | 30 if result_tag and result_tag.attr.queryid == queryid then |
29 local forwarded = message:get_child("forwarded", "urn:xmpp:forward:0"); | 31 local forwarded = message:get_child("forwarded", xmlns_forward); |
30 | 32 |
31 local delay = forwarded:get_child("delay", "urn:xmpp:delay"); | 33 local delay = forwarded:get_child("delay", xmlns_delay); |
32 local stamp = delay and delay.attr.stamp or nil; | 34 local stamp = delay and delay.attr.stamp or nil; |
33 | 35 |
34 local message = forwarded:get_child("message", "jabber:client") | 36 local message = forwarded:get_child("message", "jabber:client") |
35 | 37 |
36 results[#results+1] = { stamp = stamp, message = message }; | 38 results[#results+1] = { stamp = stamp, message = message }; |