aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/adhoc/mod_adhoc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/adhoc/mod_adhoc.lua')
-rw-r--r--plugins/adhoc/mod_adhoc.lua42
1 files changed, 20 insertions, 22 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua
index 1c956021..12e24c08 100644
--- a/plugins/adhoc/mod_adhoc.lua
+++ b/plugins/adhoc/mod_adhoc.lua
@@ -45,8 +45,8 @@ module:hook("host-disco-info-node", function (event)
end);
module:hook("host-disco-items-node", function (event)
- local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node;
- if node ~= xmlns_cmd then
+ local stanza, reply, disco_node = event.stanza, event.reply, event.node;
+ if disco_node ~= xmlns_cmd then
return;
end
@@ -69,28 +69,26 @@ module:hook("host-disco-items-node", function (event)
event.exists = true;
end);
-module:hook("iq/host/"..xmlns_cmd..":command", function (event)
+module:hook("iq-set/host/"..xmlns_cmd..":command", function (event)
local origin, stanza = event.origin, event.stanza;
- if stanza.attr.type == "set" then
- local node = stanza.tags[1].attr.node
- local command = commands[node];
- if command then
- local from = stanza.attr.from;
- local admin = is_admin(from, stanza.attr.to);
- local global_admin = is_admin(from);
- local username, hostname = jid_split(from);
- if (command.permission == "admin" and not admin)
- or (command.permission == "global_admin" and not global_admin)
- or (command.permission == "local_user" and hostname ~= module.host) then
- origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up()
- :add_child(commands[node]:cmdtag("canceled")
- :tag("note", {type="error"}):text("You don't have permission to execute this command")));
- return true
- end
- -- User has permission now execute the command
- adhoc_handle_cmd(commands[node], origin, stanza);
- return true;
+ local node = stanza.tags[1].attr.node
+ local command = commands[node];
+ if command then
+ local from = stanza.attr.from;
+ local admin = is_admin(from, stanza.attr.to);
+ local global_admin = is_admin(from);
+ local username, hostname = jid_split(from);
+ if (command.permission == "admin" and not admin)
+ or (command.permission == "global_admin" and not global_admin)
+ or (command.permission == "local_user" and hostname ~= module.host) then
+ origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up()
+ :add_child(commands[node]:cmdtag("canceled")
+ :tag("note", {type="error"}):text("You don't have permission to execute this command")));
+ return true
end
+ -- User has permission now execute the command
+ adhoc_handle_cmd(commands[node], origin, stanza);
+ return true;
end
end, 500);