Diff

mod_mam_archive/mod_mam_archive.lua @ 1477:db870913e1cf

mod_mam_archive: Doing stanza deserialization after mod_storage the right way
author syn@syn.im
date Wed, 30 Jul 2014 21:58:56 +0200
parent 1476:08ca6dd36e39
child 1498:e82592ed744b
line wrap: on
line diff
--- a/mod_mam_archive/mod_mam_archive.lua	Wed Jul 30 21:27:56 2014 +0200
+++ b/mod_mam_archive/mod_mam_archive.lua	Wed Jul 30 21:58:56 2014 +0200
@@ -268,9 +268,14 @@
 
     module:log("debug", "Count "..count);
     for id, item, when in data do
-        local tag = jid_bare(item["attr"]["from"]) == jid_bare(origin.full_jid) and "from" or "to";
+        if not getmetatable(item) == st.stanza_mt then
+            item = st.deserialize(item);
+        end
+        module:log("debug", tostring(item));
+
+        local tag = jid_bare(item.attr["from"]) == jid_bare(origin.full_jid) and "from" or "to";
         tag = chat:tag(tag, {secs = when - qstart});
-        tag:tag("body"):text(item[2][1]):up():up();
+        tag:add_child(item:get_child("body")):up();
     end
 
     origin.send(reply);