aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/adhoc/mod_adhoc.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2010-10-01 16:44:49 +0200
committerFlorian Zeitz <florob@babelmonkeys.de>2010-10-01 16:44:49 +0200
commitd78d543c9e514095409a356038da404803bfd37e (patch)
tree9d2f1c24b908f96e0b6b64132e3ab19354053f00 /plugins/adhoc/mod_adhoc.lua
parentec28fe98377d225e2c19fb3e2e4d5757a3322d3e (diff)
downloadprosody-d78d543c9e514095409a356038da404803bfd37e.tar.gz
prosody-d78d543c9e514095409a356038da404803bfd37e.zip
mod_adhoc: Answer disco#info for node=xmlns_cmd
Diffstat (limited to 'plugins/adhoc/mod_adhoc.lua')
-rw-r--r--plugins/adhoc/mod_adhoc.lua36
1 files changed, 23 insertions, 13 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua
index 9a128557..20c0f2be 100644
--- a/plugins/adhoc/mod_adhoc.lua
+++ b/plugins/adhoc/mod_adhoc.lua
@@ -17,23 +17,33 @@ 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
- 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);