Comparison

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
comparison
equal deleted inserted replaced
1476:08ca6dd36e39 1477:db870913e1cf
266 266
267 local chat = reply:tag("chat", {xmlns=xmlns_archive, with=qwith, start=date_format(qstart), version=count}); 267 local chat = reply:tag("chat", {xmlns=xmlns_archive, with=qwith, start=date_format(qstart), version=count});
268 268
269 module:log("debug", "Count "..count); 269 module:log("debug", "Count "..count);
270 for id, item, when in data do 270 for id, item, when in data do
271 local tag = jid_bare(item["attr"]["from"]) == jid_bare(origin.full_jid) and "from" or "to"; 271 if not getmetatable(item) == st.stanza_mt then
272 item = st.deserialize(item);
273 end
274 module:log("debug", tostring(item));
275
276 local tag = jid_bare(item.attr["from"]) == jid_bare(origin.full_jid) and "from" or "to";
272 tag = chat:tag(tag, {secs = when - qstart}); 277 tag = chat:tag(tag, {secs = when - qstart});
273 tag:tag("body"):text(item[2][1]):up():up(); 278 tag:add_child(item:get_child("body")):up();
274 end 279 end
275 280
276 origin.send(reply); 281 origin.send(reply);
277 return true; 282 return true;
278 end 283 end