# HG changeset patch # User Florian Zeitz # Date 1282500540 -7200 # Node ID 5a389f9f2ec7afa02da3058b4bdf733d79f3359c # Parent 84d03c44bdb9e486400f1095d0b9395fd6339257 mod_adhoc: Answer disco#info (This is a MUST in XEP-0050) diff -r 84d03c44bdb9 -r 5a389f9f2ec7 mod_adhoc/adhoc/mod_adhoc.lua --- a/mod_adhoc/adhoc/mod_adhoc.lua Sun Aug 22 12:02:41 2010 +0200 +++ b/mod_adhoc/adhoc/mod_adhoc.lua Sun Aug 22 20:09:00 2010 +0200 @@ -14,6 +14,31 @@ module:add_feature(xmlns_cmd); +module:hook("iq/host/"..xmlns_disco.."#info:query", function (event) + local origin, stanza = event.origin, event.stanza; + local node = stanza.tags[1].attr.node; + if stanza.attr.type == "get" and node + and commands[node] then + -- Required for Prosody <= 0.7 + local privileged = is_admin(stanza.attr.from) + or is_admin(stanza.attr.from, stanza.attr.to); + if (commands[node].permission == "admin" and privileged) + or (commands[node].permission == "user") then + reply = st.reply(stanza); + reply:tag("query", { xmlns = xmlns_disco.."#info", + node = node }); + reply:tag("identity", { name = commands[node].name, + category = "automation", type = "command-node" }):up(); + reply:tag("feature", { var = xmlns_cmd }):up(); + reply:tag("feature", { var = "jabber:x:data" }):up(); + else + reply = st.error_reply(stanza, "auth", "forbidden", "This item is not available to you"); + end + origin.send(reply); + return true; + end +end); + module:hook("iq/host/"..xmlns_disco.."#items:query", function (event) local origin, stanza = event.origin, event.stanza; if stanza.attr.type == "get" and stanza.tags[1].attr.node