mod_rest: Fix handling of 'node' attribute in disco#info
authorKim Alvefur <zash@zash.se>
Sat, 25 Jan 2020 02:03:30 +0100
changeset 3863 da3a0f055526
parent 3862 29c39876c4af
child 3864 9752a6f1b9f3
mod_rest: Fix handling of 'node' attribute in disco#info This way also ensures it's covered by type checks in util.stanza
mod_rest/jsonmap.lib.lua
--- a/mod_rest/jsonmap.lib.lua	Sat Jan 25 01:55:23 2020 +0100
+++ b/mod_rest/jsonmap.lib.lua	Sat Jan 25 02:03:30 2020 +0100
@@ -77,9 +77,8 @@
 			return { node = s.attr.node, identities = identities, features = features, };
 		end;
 		function  (s)
-			local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" });
 			if type(s) == "table" then
-				disco.attr.node = tostring(s.node);
+				local disco = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info", node = s.node });
 				if s.identities then
 					for _, identity in ipairs(s.identities) do
 						disco:tag("identity", { category = identity.category, type = identity.type, name = identity.name }):up();
@@ -90,8 +89,10 @@
 						disco:tag("feature", { var = feature }):up();
 					end
 				end
+				return disco;
+			else
+				st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info", });
 			end
-			return disco;
 		end;
 	};