# HG changeset patch # User Kim Alvefur # Date 1650192705 -7200 # Node ID 77b7e13222812faa01ba63be2c25ef932928a97b # Parent b8366e31c8292e99f4088d241652b51ce77f44ca mod_rest: Add some notes about custom disco#info mapping code diff -r b8366e31c829 -r 77b7e1322281 mod_rest/jsonmap.lib.lua --- a/mod_rest/jsonmap.lib.lua Sun Apr 17 12:49:06 2022 +0200 +++ b/mod_rest/jsonmap.lib.lua Sun Apr 17 12:51:45 2022 +0200 @@ -50,6 +50,8 @@ return s.attr.node or true; end local identities, features, extensions = array(), array(), {}; + + -- features and identities could be done with util.datamapper for tag in s:childtags() do if tag.name == "identity" and tag.attr.category and tag.attr.type then identities:push({ category = tag.attr.category, type = tag.attr.type, name = tag.attr.name }); @@ -57,6 +59,8 @@ features:push(tag.attr.var); end end + + -- Especially this would be hard to do with util.datamapper for form in s:childtags("x", "jabber:x:data") do local jform = field_mappings.formdata.st2json(form); local form_type = jform["FORM_TYPE"]; @@ -65,6 +69,7 @@ extensions[form_type] = jform; end end + if next(extensions) == nil then extensions = nil; end return { node = s.attr.node, identities = identities, features = features, extensions = extensions }; end;