changeset 3859:da3a0f055526

mod_rest: Fix handling of 'node' attribute in disco#info This way also ensures it's covered by type checks in util.stanza
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2020 02:03:30 +0100
parents 29c39876c4af
children 9752a6f1b9f3
files mod_rest/jsonmap.lib.lua
diffstat 1 files changed, 4 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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;
 	};