Changeset

9405:86e3e37f25ff

mod_admin_telnet: Use prosody.hosts to be more explicit and avoid name clash with 'hosts' arguments [luacheck]
author Kim Alvefur <zash@zash.se>
date Sun, 30 Sep 2018 14:33:42 +0200
parents 9404:f40b0cd41a87
children 9406:7f277975768d
files plugins/mod_admin_telnet.lua
diffstat 1 files changed, 14 insertions(+), 15 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_admin_telnet.lua	Sun Sep 30 14:32:32 2018 +0200
+++ b/plugins/mod_admin_telnet.lua	Sun Sep 30 14:33:42 2018 +0200
@@ -18,7 +18,6 @@
 local _G = _G;
 
 local prosody = _G.prosody;
-local hosts = prosody.hosts;
 
 local console_listener = { default_port = 5582; default_mode = "*a"; interface = "127.0.0.1" };
 
@@ -948,9 +947,9 @@
 
 local function check_muc(jid)
 	local room_name, host = jid_split(jid);
-	if not hosts[host] then
+	if not prosody.hosts[host] then
 		return nil, "No such host: "..host;
-	elseif not hosts[host].modules.muc then
+	elseif not prosody.hosts[host].modules.muc then
 		return nil, "Host '"..host.."' is not a MUC service";
 	end
 	return room_name, host;
@@ -963,8 +962,8 @@
 	end
 	if not room_name then return nil, host end
 	if config ~= nil and type(config) ~= "table" then return nil, "Config must be a table"; end
-	if hosts[host].modules.muc.get_room_from_jid(room_jid) then return nil, "Room exists already" end
-	return hosts[host].modules.muc.create_room(room_jid, config);
+	if prosody.hosts[host].modules.muc.get_room_from_jid(room_jid) then return nil, "Room exists already" end
+	return prosody.hosts[host].modules.muc.create_room(room_jid, config);
 end
 
 function def_env.muc:room(room_jid)
@@ -972,7 +971,7 @@
 	if not room_name then
 		return room_name, host;
 	end
-	local room_obj = hosts[host].modules.muc.get_room_from_jid(room_jid);
+	local room_obj = prosody.hosts[host].modules.muc.get_room_from_jid(room_jid);
 	if not room_obj then
 		return nil, "No such room: "..room_jid;
 	end
@@ -980,7 +979,7 @@
 end
 
 function def_env.muc:list(host)
-	local host_session = hosts[host];
+	local host_session = prosody.hosts[host];
 	if not host_session or not host_session.modules.muc then
 		return nil, "Please supply the address of a local MUC component";
 	end
@@ -998,7 +997,7 @@
 def_env.user = {};
 function def_env.user:create(jid, password)
 	local username, host = jid_split(jid);
-	if not hosts[host] then
+	if not prosody.hosts[host] then
 		return nil, "No such host: "..host;
 	elseif um.user_exists(username, host) then
 		return nil, "User exists";
@@ -1013,7 +1012,7 @@
 
 function def_env.user:delete(jid)
 	local username, host = jid_split(jid);
-	if not hosts[host] then
+	if not prosody.hosts[host] then
 		return nil, "No such host: "..host;
 	elseif not um.user_exists(username, host) then
 		return nil, "No such user";
@@ -1028,7 +1027,7 @@
 
 function def_env.user:password(jid, password)
 	local username, host = jid_split(jid);
-	if not hosts[host] then
+	if not prosody.hosts[host] then
 		return nil, "No such host: "..host;
 	elseif not um.user_exists(username, host) then
 		return nil, "No such user";
@@ -1044,7 +1043,7 @@
 function def_env.user:list(host, pat)
 	if not host then
 		return nil, "No host given";
-	elseif not hosts[host] then
+	elseif not prosody.hosts[host] then
 		return nil, "No such host";
 	end
 	local print = self.session.print;
@@ -1063,9 +1062,9 @@
 
 local st = require "util.stanza";
 function def_env.xmpp:ping(localhost, remotehost)
-	if hosts[localhost] then
+	if prosody.hosts[localhost] then
 		module:send(st.iq{ from=localhost, to=remotehost, type="get", id="ping" }
-				:tag("ping", {xmlns="urn:xmpp:ping"}), hosts[localhost]);
+				:tag("ping", {xmlns="urn:xmpp:ping"}), prosody.hosts[localhost]);
 		return true, "Sent ping";
 	else
 		return nil, "No such host";
@@ -1143,10 +1142,10 @@
 function def_env.debug:events(host, event)
 	local events_obj;
 	if host and host ~= "*" then
-		if not hosts[host] then
+		if not prosody.hosts[host] then
 			return false, "Unknown host: "..host;
 		end
-		events_obj = hosts[host].events;
+		events_obj = prosody.hosts[host].events;
 	else
 		events_obj = prosody.events;
 	end