Changeset

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
parents 2419:045d594a3707
children 2421:a9add2d1adf5
files mod_storage_xmlarchive/mod_storage_xmlarchive.lua
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Mon Dec 19 07:43:28 2016 +0100
+++ b/mod_storage_xmlarchive/mod_storage_xmlarchive.lua	Mon Dec 19 07:47:50 2016 +0100
@@ -20,11 +20,15 @@
 local archive = {};
 local archive_mt = { __index = archive };
 
+local is_stanza = st.is_stanza or function (s)
+	return getmetatable(s) == st.stanza_mt;
+end
+
 function archive:append(username, _, data, when, with)
 	if type(when) ~= "number" then
 		when, with, data = data, when, with;
 	end
-	if getmetatable(data) ~= st.stanza_mt then
+	if not is_stanza(data) then
 		module:log("error", "Attempt to store non-stanza object, traceback: %s", debug.traceback());
 		return nil, "unsupported-datatype";
 	end