# HG changeset patch # User Kim Alvefur # Date 1579909238 -3600 # Node ID 25c34c9f755c945c0742458409630d47be265d10 # Parent fb29d7cd698b3a1cc6810861d1f13a745e304e3a mod_rest: Add mapping of XEP-0092: Software Version diff -r fb29d7cd698b -r 25c34c9f755c mod_rest/example/app.py --- a/mod_rest/example/app.py Sat Jan 25 00:37:06 2020 +0100 +++ b/mod_rest/example/app.py Sat Jan 25 00:40:38 2020 +0100 @@ -44,6 +44,9 @@ {"items": [{"jid": "example.org", "name": "Example Dot Org"}]} ) + elif "version" in data: + return jsonify({"version": {"name": "app.py", "version": "0"}}) + return Response(status=501) diff -r fb29d7cd698b -r 25c34c9f755c mod_rest/jsonmap.lib.lua --- 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",