Diff

mod_rest/jsonmap.lib.lua @ 4927: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
parent 4916:3dc8e329d233
child 4935:a85efae90e21
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;