diff options
author | Florian Zeitz <florob@babelmonkeys.de> | 2013-07-24 22:08:07 +0200 |
---|---|---|
committer | Florian Zeitz <florob@babelmonkeys.de> | 2013-07-24 22:08:07 +0200 |
commit | 824b497b4b9617631f3f9e89a937d36baa853bd1 (patch) | |
tree | 7b8cb733a4ba5d5de21c6e500872226a45c1a600 | |
parent | e2d04faa20852946634b527c097a0315d6621d73 (diff) | |
download | prosody-824b497b4b9617631f3f9e89a937d36baa853bd1.tar.gz prosody-824b497b4b9617631f3f9e89a937d36baa853bd1.zip |
mod_adhoc: Sort commands by node. This guarantees the order remains the same across restarts etc.
-rw-r--r-- | plugins/adhoc/mod_adhoc.lua | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/plugins/adhoc/mod_adhoc.lua b/plugins/adhoc/mod_adhoc.lua index 69b2c8da..73744969 100644 --- a/plugins/adhoc/mod_adhoc.lua +++ b/plugins/adhoc/mod_adhoc.lua @@ -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 @@ module:hook("iq/host/"..xmlns_disco.."#items:query", function (event) 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 |