aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_storage_sql2.lua
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
commit298aef6be73d7b454f14d784d21cdcba55c7a804 (patch)
treea12e70a9141326c2948b0965ef084a7a6cf571ae /plugins/mod_storage_sql2.lua
parent1e1834a4ec05554473438f43f44c34e2809a330f (diff)
downloadprosody-298aef6be73d7b454f14d784d21cdcba55c7a804.tar.gz
prosody-298aef6be73d7b454f14d784d21cdcba55c7a804.zip
mod_storage_sql2: Support XML serialization for stanzas.
Diffstat (limited to 'plugins/mod_storage_sql2.lua')
-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