aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-07-10 13:19:33 +0200
committerKim Alvefur <zash@zash.se>2013-07-10 13:19:33 +0200
commit6bae3611e9c8e534d5c4cceca18e541819d52462 (patch)
treea12e70a9141326c2948b0965ef084a7a6cf571ae /plugins
parent127153f466392333464b986d3a7224f49ee1d899 (diff)
downloadprosody-6bae3611e9c8e534d5c4cceca18e541819d52462.tar.gz
prosody-6bae3611e9c8e534d5c4cceca18e541819d52462.zip
mod_storage_sql2: Support XML serialization for stanzas.
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_storage_sql2.lua9
1 files changed, 9 insertions, 0 deletions
diff --git a/plugins/mod_storage_sql2.lua b/plugins/mod_storage_sql2.lua
index 48da2d46..8081c0f9 100644
--- a/plugins/mod_storage_sql2.lua
+++ b/plugins/mod_storage_sql2.lua
@@ -1,7 +1,12 @@
local json = require "util.json";
+local xml_parse = require "util.xml".parse;
local resolve_relative_path = require "core.configmanager".resolve_relative_path;
+local stanza_mt = require"util.stanza".stanza_mt;
+local getmetatable = getmetatable;
+local function is_stanza(x) return getmetatable(x) == stanza_mt; end
+
local unpack = unpack
local function iterator(result)
return function(result)
@@ -134,6 +139,8 @@ local function serialize(value)
local t = type(value);
if t == "string" or t == "boolean" or t == "number" then
return t, tostring(value);
+ elseif is_stanza(value) then
+ return "xml", tostring(value);
elseif t == "table" then
local value,err = json.encode(value);
if value then return "json", value; end
@@ -149,6 +156,8 @@ local function deserialize(t, value)
elseif t == "number" then return tonumber(value);
elseif t == "json" then
return json.decode(value);
+ elseif t == "xml" then
+ return xml_parse(value);
end
end