aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2018-09-21 14:37:18 +0100
committerMatthew Wild <mwild1@gmail.com>2018-09-21 14:37:18 +0100
commit83b4ed2470176bc8240bb6a47d38b024988a418a (patch)
treee38f764d11df29bc77a7f91d597fc03ed1dcdb43
parentcceeea2c2864e8617b987a90985108bbdf3fe1b3 (diff)
downloadprosody-83b4ed2470176bc8240bb6a47d38b024988a418a.tar.gz
prosody-83b4ed2470176bc8240bb6a47d38b024988a418a.zip
mod_adhoc: Use util.iterators.sorted_pairs() to sort commands
-rw-r--r--plugins/adhoc/mod_adhoc.lua7
1 files changed, 2 insertions, 5 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua
index 12e24c08..1ccea419 100644
--- a/plugins/adhoc/mod_adhoc.lua
+++ b/plugins/adhoc/mod_adhoc.lua
@@ -5,9 +5,8 @@
-- COPYING file in the source package for more information.
--
+local it = require "util.iterators";
local st = require "util.stanza";
-local keys = require "util.iterators".keys;
-local array_collect = require "util.array".collect;
local is_admin = require "core.usermanager".is_admin;
local jid_split = require "util.jid".split;
local adhoc_handle_cmd = module:require "adhoc".handle_cmd;
@@ -54,9 +53,7 @@ module:hook("host-disco-items-node", function (event)
local admin = is_admin(from, stanza.attr.to);
local global_admin = is_admin(from);
local username, hostname = jid_split(from);
- local nodes = array_collect(keys(commands)):sort();
- for _, node in ipairs(nodes) do
- local command = commands[node];
+ for node, command in it.sorted_pairs(commands) do
if (command.permission == "admin" and admin)
or (command.permission == "global_admin" and global_admin)
or (command.permission == "local_user" and hostname == module.host)