# HG changeset patch # User Florian Zeitz # Date 1285942536 -7200 # Node ID 9b4a114b2fe67b81dbe8a41a1c404a987fc161bd # Parent 8eae74a31acb954553b3b849fd9446f1b1c78443 mod_adhoc: Answer disco#info for node=xmlns_cmd diff -r 8eae74a31acb -r 9b4a114b2fe6 mod_adhoc/adhoc/mod_adhoc.lua --- a/mod_adhoc/adhoc/mod_adhoc.lua Mon Sep 20 21:10:49 2010 +0100 +++ b/mod_adhoc/adhoc/mod_adhoc.lua Fri Oct 01 16:15:36 2010 +0200 @@ -17,25 +17,34 @@ 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 + if stanza.attr.type == "get" and node then + if 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; + 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);