Comparison

mod_storage_xmlarchive/mod_storage_xmlarchive.lua @ 2420:309db11494c2

mod_storage_xmlarchive: Use util.stanza.is_stanza if available
author Kim Alvefur <zash@zash.se>
date Mon, 19 Dec 2016 07:47:50 +0100
parent 2405:7bce126bf60c
child 2514:d47a7e6e9adc
comparison
equal deleted inserted replaced
2419:045d594a3707 2420:309db11494c2
18 end 18 end
19 19
20 local archive = {}; 20 local archive = {};
21 local archive_mt = { __index = archive }; 21 local archive_mt = { __index = archive };
22 22
23 local is_stanza = st.is_stanza or function (s)
24 return getmetatable(s) == st.stanza_mt;
25 end
26
23 function archive:append(username, _, data, when, with) 27 function archive:append(username, _, data, when, with)
24 if type(when) ~= "number" then 28 if type(when) ~= "number" then
25 when, with, data = data, when, with; 29 when, with, data = data, when, with;
26 end 30 end
27 if getmetatable(data) ~= st.stanza_mt then 31 if not is_stanza(data) then
28 module:log("error", "Attempt to store non-stanza object, traceback: %s", debug.traceback()); 32 module:log("error", "Attempt to store non-stanza object, traceback: %s", debug.traceback());
29 return nil, "unsupported-datatype"; 33 return nil, "unsupported-datatype";
30 end 34 end
31 35
32 username = username or "@"; 36 username = username or "@";