changeset 4928:77b7e1322281

mod_rest: Add some notes about custom disco#info mapping code
author Kim Alvefur <zash@zash.se>
date Sun, 17 Apr 2022 12:51:45 +0200
parents b8366e31c829
children d5612dcf6733
files mod_rest/jsonmap.lib.lua
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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;