Software /
code /
prosody
Changeset
3511:4495403470cb
mod_adhoc: Answer disco#info for node=xmlns_cmd
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Fri, 01 Oct 2010 16:44:49 +0200 |
parents | 3510:711eb5bf94b4 |
children | 3512:e344b00f2cc9 |
files | plugins/adhoc/mod_adhoc.lua |
diffstat | 1 files changed, 23 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/plugins/adhoc/mod_adhoc.lua Tue Sep 28 16:36:17 2010 +0500 +++ b/plugins/adhoc/mod_adhoc.lua Fri Oct 01 16:44:49 2010 +0200 @@ -17,23 +17,33 @@ 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 - local privileged = is_admin(stanza.attr.from, stanza.attr.to); - if (commands[node].permission == "admin" and privileged) - or (commands[node].permission == "user") then + if stanza.attr.type == "get" and node then + if commands[node] then + local privileged = 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; + elseif node == xmlns_cmd 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"); + reply:tag("identity", { name = "Ad-Hoc Commands", + category = "automation", type = "command-list" }):up(); + origin.send(reply); + return true; + end - origin.send(reply); - return true; end end);