Diff

mod_rest/jsonmap.lib.lua @ 3854:25c34c9f755c

mod_rest: Add mapping of XEP-0092: Software Version
author Kim Alvefur <zash@zash.se>
date Sat, 25 Jan 2020 00:40:38 +0100
parent 3852:66f96b98d219
child 3855:0e1e900577c4
line wrap: on
line diff
--- a/mod_rest/jsonmap.lib.lua	Sat Jan 25 00:37:06 2020 +0100
+++ b/mod_rest/jsonmap.lib.lua	Sat Jan 25 00:40:38 2020 +0100
@@ -41,6 +41,28 @@
 	-- XEP-0199
 	ping = {"bool_tag", "urn:xmpp:ping", "ping"},
 
+	-- XEP-0092: Software Version
+	version = {"func", "jabber:iq:version", "query",
+		function (s)
+			return {
+				name = s:get_child_text("name");
+				version = s:get_child_text("version");
+				os = s:get_child_text("os");
+			}
+		end,
+		function (s)
+			local v = st.stanza("query", { xmlns = "jabber:iq:version" });
+			if type(s) == "table" then
+				v:text_tag("name", s.name);
+				v:text_tag("version", s.version);
+				if s.os then
+					v:text_tag("os", s.os);
+				end
+			end
+			return v;
+		end
+	};
+
 	-- XEP-0030
 	disco = {
 		"func", "http://jabber.org/protocol/disco#info", "query",
@@ -135,6 +157,7 @@
 	disco = "iq",
 	items = "iq",
 	ping = "iq",
+	version = "iq",
 
 	body = "message",
 	html = "message",