aboutsummaryrefslogtreecommitdiffstats
path: root/util/datamapper.lua
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-03-07 01:41:39 +0100
committerKim Alvefur <zash@zash.se>2021-03-07 01:41:39 +0100
commit7cd2803161ee05303371cd681f8ae00a0838d07f (patch)
treec9c4cce37f9470109870f19cbc5c93c7db3674cf /util/datamapper.lua
parentd20ea9b87e6e4071aca1a6895041d9e82ebb8691 (diff)
downloadprosody-7cd2803161ee05303371cd681f8ae00a0838d07f.tar.gz
prosody-7cd2803161ee05303371cd681f8ae00a0838d07f.zip
util.datamapper: Add logic for "boolean" tags here the presence means true
Diffstat (limited to 'util/datamapper.lua')
-rw-r--r--util/datamapper.lua12
1 files changed, 9 insertions, 3 deletions
diff --git a/util/datamapper.lua b/util/datamapper.lua
index 82532f0c..a87b21ae 100644
--- a/util/datamapper.lua
+++ b/util/datamapper.lua
@@ -48,8 +48,10 @@ local function parse_object(schema, s)
if name_is_value then
local c = s:get_child(nil, namespace);
- if c then
+ if c and proptype == "string" then
out[prop] = c.name;
+ elseif proptype == "boolean" and c then
+ out[prop] = true;
end
elseif is_attribute then
local attr = name
@@ -182,8 +184,12 @@ local function unparse(schema, t, current_name, current_ns)
if namespace ~= current_ns then
propattr = {xmlns = namespace}
end
- if name_is_value and type(v) == "string" then
- out:tag(v, propattr):up();
+ if name_is_value then
+ if proptype == "string" and type(v) == "string" then
+ out:tag(v, propattr):up();
+ elseif proptype == "boolean" and v == true then
+ out:tag(name, propattr):up();
+ end
elseif proptype == "string" and type(v) == "string" then
out:text_tag(name, v, propattr)
elseif proptype == "number" and type(v) == "number" then