Changeset

9331:2f634cc02eac

mod_adhoc: Use util.iterators.sorted_pairs() to sort commands
author Matthew Wild <mwild1@gmail.com>
date Fri, 21 Sep 2018 14:37:18 +0100
parents 9330:36badabc85ce
children 9332:048389a9bbd4
files plugins/adhoc/mod_adhoc.lua
diffstat 1 files changed, 2 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/adhoc/mod_adhoc.lua	Fri Sep 21 14:36:29 2018 +0100
+++ b/plugins/adhoc/mod_adhoc.lua	Fri Sep 21 14:37:18 2018 +0100
@@ -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 @@
 	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)