Software /
code /
verse
Diff
plugins/archive.lua @ 409:171c4a8cc3de
plugins.archive: Update to XEP-0313 v0.6
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 07 Apr 2017 19:38:52 +0200 |
parent | 380:0891b4e27766 |
child | 412:ef66f302fe97 |
line wrap: on
line diff
--- a/plugins/archive.lua Fri Apr 07 19:37:56 2017 +0200 +++ b/plugins/archive.lua Fri Apr 07 19:38:52 2017 +0200 @@ -4,7 +4,7 @@ local verse = require "verse"; local st = require "util.stanza"; -local xmlns_mam = "urn:xmpp:mam:0" +local xmlns_mam = "urn:xmpp:mam:2" local xmlns_forward = "urn:xmpp:forward:0"; local xmlns_delay = "urn:xmpp:delay"; local uuid = require "util.uuid".generate; @@ -39,14 +39,6 @@ local results = {}; local function handle_archived_message(message) - local finnished = message:get_child("fin", xmlns_mam) - if finnished and finnished.attr.queryid == queryid then - local rset = rsm.get(finnished); - for k,v in pairs(rset or NULL) do results[k]=v; end - self:unhook("message", handle_archived_message); - callback(results); - return true - end local result_tag = message:get_child("result", xmlns_mam); if result_tag and result_tag.attr.queryid == queryid then local forwarded = result_tag:get_child("forwarded", xmlns_forward); @@ -65,12 +57,19 @@ self:hook("message", handle_archived_message, 1); self:send_iq(query_st, function(reply) + self:unhook("message", handle_archived_message); if reply.attr.type == "error" then self:warn(table.concat({reply:get_error()}, " ")) - self:unhook("message", handle_archived_message); callback(false, reply:get_error()) + return true; end - return true + local finnished = reply:get_child("fin", xmlns_mam) + if finnished and finnished.attr.queryid == queryid then + local rset = rsm.get(finnished); + for k,v in pairs(rset or NULL) do results[k]=v; end + callback(results); + return true + end end); end