Comparison

plugins/adhoc/mod_adhoc.lua @ 10542:f1886a48a6d4

mod_adhoc: Remove unused variable [luacheck]
author Kim Alvefur <zash@zash.se>
date Mon, 23 Dec 2019 21:34:34 +0100
parent 9571:5c475f6e89a4
child 10565:421b2f8369fd
comparison
equal deleted inserted replaced
10541:6c6ff4509082 10542:f1886a48a6d4
6 -- 6 --
7 7
8 local it = require "util.iterators"; 8 local it = require "util.iterators";
9 local st = require "util.stanza"; 9 local st = require "util.stanza";
10 local is_admin = require "core.usermanager".is_admin; 10 local is_admin = require "core.usermanager".is_admin;
11 local jid_split = require "util.jid".split; 11 local jid_host = require "util.jid".host;
12 local adhoc_handle_cmd = module:require "adhoc".handle_cmd; 12 local adhoc_handle_cmd = module:require "adhoc".handle_cmd;
13 local xmlns_cmd = "http://jabber.org/protocol/commands"; 13 local xmlns_cmd = "http://jabber.org/protocol/commands";
14 local commands = {}; 14 local commands = {};
15 15
16 module:add_feature(xmlns_cmd); 16 module:add_feature(xmlns_cmd);
19 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node; 19 local stanza, origin, reply, node = event.stanza, event.origin, event.reply, event.node;
20 if commands[node] then 20 if commands[node] then
21 local from = stanza.attr.from; 21 local from = stanza.attr.from;
22 local privileged = is_admin(from, stanza.attr.to); 22 local privileged = is_admin(from, stanza.attr.to);
23 local global_admin = is_admin(from); 23 local global_admin = is_admin(from);
24 local username, hostname = jid_split(from); 24 local hostname = jid_host(from);
25 local command = commands[node]; 25 local command = commands[node];
26 if (command.permission == "admin" and privileged) 26 if (command.permission == "admin" and privileged)
27 or (command.permission == "global_admin" and global_admin) 27 or (command.permission == "global_admin" and global_admin)
28 or (command.permission == "local_user" and hostname == module.host) 28 or (command.permission == "local_user" and hostname == module.host)
29 or (command.permission == "user") then 29 or (command.permission == "user") then
50 end 50 end
51 51
52 local from = stanza.attr.from; 52 local from = stanza.attr.from;
53 local admin = is_admin(from, stanza.attr.to); 53 local admin = is_admin(from, stanza.attr.to);
54 local global_admin = is_admin(from); 54 local global_admin = is_admin(from);
55 local username, hostname = jid_split(from); 55 local hostname = jid_host(from);
56 for node, command in it.sorted_pairs(commands) do 56 for node, command in it.sorted_pairs(commands) do
57 if (command.permission == "admin" and admin) 57 if (command.permission == "admin" and admin)
58 or (command.permission == "global_admin" and global_admin) 58 or (command.permission == "global_admin" and global_admin)
59 or (command.permission == "local_user" and hostname == module.host) 59 or (command.permission == "local_user" and hostname == module.host)
60 or (command.permission == "user") then 60 or (command.permission == "user") then
72 local command = commands[node]; 72 local command = commands[node];
73 if command then 73 if command then
74 local from = stanza.attr.from; 74 local from = stanza.attr.from;
75 local admin = is_admin(from, stanza.attr.to); 75 local admin = is_admin(from, stanza.attr.to);
76 local global_admin = is_admin(from); 76 local global_admin = is_admin(from);
77 local username, hostname = jid_split(from); 77 local hostname = jid_host(from);
78 if (command.permission == "admin" and not admin) 78 if (command.permission == "admin" and not admin)
79 or (command.permission == "global_admin" and not global_admin) 79 or (command.permission == "global_admin" and not global_admin)
80 or (command.permission == "local_user" and hostname ~= module.host) then 80 or (command.permission == "local_user" and hostname ~= module.host) then
81 origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up() 81 origin.send(st.error_reply(stanza, "auth", "forbidden", "You don't have permission to execute this command"):up()
82 :add_child(commands[node]:cmdtag("canceled") 82 :add_child(commands[node]:cmdtag("canceled")