equal
deleted
inserted
replaced
3 -- |
3 -- |
4 -- This file is MIT/X11 licensed. Please see the |
4 -- This file is MIT/X11 licensed. Please see the |
5 -- COPYING file in the source package for more information. |
5 -- COPYING file in the source package for more information. |
6 -- |
6 -- |
7 |
7 |
|
8 local it = require "util.iterators"; |
8 local st = require "util.stanza"; |
9 local st = require "util.stanza"; |
9 local keys = require "util.iterators".keys; |
|
10 local array_collect = require "util.array".collect; |
|
11 local is_admin = require "core.usermanager".is_admin; |
10 local is_admin = require "core.usermanager".is_admin; |
12 local jid_split = require "util.jid".split; |
11 local jid_split = require "util.jid".split; |
13 local adhoc_handle_cmd = module:require "adhoc".handle_cmd; |
12 local adhoc_handle_cmd = module:require "adhoc".handle_cmd; |
14 local xmlns_cmd = "http://jabber.org/protocol/commands"; |
13 local xmlns_cmd = "http://jabber.org/protocol/commands"; |
15 local commands = {}; |
14 local commands = {}; |
52 |
51 |
53 local from = stanza.attr.from; |
52 local from = stanza.attr.from; |
54 local admin = is_admin(from, stanza.attr.to); |
53 local admin = is_admin(from, stanza.attr.to); |
55 local global_admin = is_admin(from); |
54 local global_admin = is_admin(from); |
56 local username, hostname = jid_split(from); |
55 local username, hostname = jid_split(from); |
57 local nodes = array_collect(keys(commands)):sort(); |
56 for node, command in it.sorted_pairs(commands) do |
58 for _, node in ipairs(nodes) do |
|
59 local command = commands[node]; |
|
60 if (command.permission == "admin" and admin) |
57 if (command.permission == "admin" and admin) |
61 or (command.permission == "global_admin" and global_admin) |
58 or (command.permission == "global_admin" and global_admin) |
62 or (command.permission == "local_user" and hostname == module.host) |
59 or (command.permission == "local_user" and hostname == module.host) |
63 or (command.permission == "user") then |
60 or (command.permission == "user") then |
64 reply:tag("item", { name = command.name, |
61 reply:tag("item", { name = command.name, |