Software /
code /
prosody
Changeset
5735:24f4e73645fe
mod_storage_sql2: Support XML serialization for stanzas.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 10 Jul 2013 13:19:33 +0200 |
parents | 5734:49f1fed6e25e |
children | 5737:3be189b50394 |
files | plugins/mod_storage_sql2.lua |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/mod_storage_sql2.lua Wed Jul 10 13:18:10 2013 +0200 +++ b/plugins/mod_storage_sql2.lua Wed Jul 10 13:19:33 2013 +0200 @@ -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 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 @@ 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