mod_rest: Apply JSON mapping to items in <xmpp> container (e.g. MAM results etc)
authorKim Alvefur <zash@zash.se>
Wed, 27 Oct 2021 20:43:17 +0200
changeset 4735 d71beacaec3b
parent 4734 1da4b815d2fe
child 4736 607cac9b9393
mod_rest: Apply JSON mapping to items in <xmpp> container (e.g. MAM results etc)
mod_rest/jsonmap.lib.lua
--- a/mod_rest/jsonmap.lib.lua	Wed Oct 27 19:12:03 2021 +0100
+++ b/mod_rest/jsonmap.lib.lua	Wed Oct 27 20:43:17 2021 +0200
@@ -406,6 +406,13 @@
 }
 
 local function st2json(s)
+	if s.name == "xmpp" then
+		local result = array();
+		for child in s:childtags() do
+			result:push(st2json(child));
+		end
+		return { xmpp = result };
+	end
 	local t = map.parse(schema.properties[s.name], s);
 
 	t.kind = s.name;