aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/adhoc
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
commitf82932edecb47b3c0c07f2c8e281621e6f695b55 (patch)
treee38f764d11df29bc77a7f91d597fc03ed1dcdb43 /plugins/adhoc
parent391fe2828f55d1d3298a31ae625ba74c575e25a1 (diff)
downloadprosody-f82932edecb47b3c0c07f2c8e281621e6f695b55.tar.gz
prosody-f82932edecb47b3c0c07f2c8e281621e6f695b55.zip
mod_adhoc: Use util.iterators.sorted_pairs() to sort commands
Diffstat (limited to 'plugins/adhoc')
-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)