diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2010-08-22 20:53:40 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2010-08-22 20:53:40 +0200 |
commit | a29ced4e879f44932c14ad182daf536eefe2e303 (patch) | |
tree | b18b3e6a988747c507c14f5b6daf561fcd19e026 /plugins | |
parent | c6b7b0576866581c203710c470b895c0fb8d9500 (diff) | |
download | prosody-a29ced4e879f44932c14ad182daf536eefe2e303.tar.gz prosody-a29ced4e879f44932c14ad182daf536eefe2e303.zip |
mod_adhoc: Answer disco#info (This is a MUST in XEP-0050)
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/adhoc/mod_adhoc.lua | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua index 211956be..181652e4 100644 --- a/plugins/adhoc/mod_adhoc.lua +++ b/plugins/adhoc/mod_adhoc.lua @@ -14,6 +14,31 @@ local commands = {}; 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 |