# HG changeset patch # User Kim Alvefur # Date 1491586732 -7200 # Node ID 171c4a8cc3de18f125a281b1ee8e9c29964fc04b # Parent 635cbd979d7b186e13718e78dc4ad65c0d96706f plugins.archive: Update to XEP-0313 v0.6 diff -r 635cbd979d7b -r 171c4a8cc3de plugins/archive.lua --- 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