From f82932edecb47b3c0c07f2c8e281621e6f695b55 Mon Sep 17 00:00:00 2001 From: Matthew Wild Date: Fri, 21 Sep 2018 14:37:18 +0100 Subject: mod_adhoc: Use util.iterators.sorted_pairs() to sort commands --- plugins/adhoc/mod_adhoc.lua | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'plugins/adhoc') 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) -- cgit v1.2.3