# HG changeset patch # User Florian Zeitz <florob@babelmonkeys.de> # Date 1374696487 -7200 # Node ID e599d9a367cfa07c796f17eb26fc8b00b53318fd # Parent 767e29b2cd3afc6bf0a60a22810964450a2dd60c mod_adhoc: Sort commands by node. This guarantees the order remains the same across restarts etc. diff -r 767e29b2cd3a -r e599d9a367cf plugins/adhoc/mod_adhoc.lua --- a/plugins/adhoc/mod_adhoc.lua Wed Jul 24 21:50:38 2013 +0200 +++ b/plugins/adhoc/mod_adhoc.lua Wed Jul 24 22:08:07 2013 +0200 @@ -6,6 +6,8 @@ -- 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 adhoc_handle_cmd = module:require "adhoc".handle_cmd; local xmlns_cmd = "http://jabber.org/protocol/commands"; @@ -56,7 +58,9 @@ reply = st.reply(stanza); reply:tag("query", { xmlns = xmlns_disco.."#items", node = xmlns_cmd }); - for node, command in pairs(commands) do + local nodes = array_collect(keys(commands)):sort(); + for _, node in ipairs(nodes) do + local command = commands[node]; if (command.permission == "admin" and admin) or (command.permission == "global_admin" and global_admin) or (command.permission == "user") then