aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/adhoc
diff options
context:
space:
mode:
authorEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-08-24 20:34:00 +0200
committerEmmanuel Gil Peyrot <linkmauve@linkmauve.fr>2018-08-24 20:34:00 +0200
commita70ba0645cc77984827877e2dba62baf84aa1d68 (patch)
treed8e0d15880fc3c232c392f12a499505a0ac14a8b /plugins/adhoc
parent4202869a5a19b466746cce57e8576f5664a6f218 (diff)
downloadprosody-a70ba0645cc77984827877e2dba62baf84aa1d68.tar.gz
prosody-a70ba0645cc77984827877e2dba62baf84aa1d68.zip
mod_adhoc: Simplify iq handling by hooking on iq-set/ instead of iq/.
Diffstat (limited to 'plugins/adhoc')
-rw-r--r--plugins/adhoc/mod_adhoc.lua38
1 files changed, 18 insertions, 20 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua
index 8ffdc7de..12e24c08 100644
--- a/plugins/adhoc/mod_adhoc.lua
+++ b/plugins/adhoc/mod_adhoc.lua
@@ -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);