mod_admin_telnet: Sort hosts in module:list
authorKim Alvefur <zash@zash.se>
Sun, 15 Dec 2019 22:08:20 +0100
changeset 10512 edd323b30de1
parent 10511 4d3549e64489
child 10513 0aa0fd1adbb0
mod_admin_telnet: Sort hosts in module:list
plugins/mod_admin_telnet.lua
--- a/plugins/mod_admin_telnet.lua	Sun Dec 15 22:07:24 2019 +0100
+++ b/plugins/mod_admin_telnet.lua	Sun Dec 15 22:08:20 2019 +0100
@@ -466,16 +466,7 @@
 end
 
 function def_env.module:list(hosts)
-	if hosts == nil then
-		hosts = array.collect(keys(prosody.hosts));
-		table.insert(hosts, 1, "*");
-	end
-	if type(hosts) == "string" then
-		hosts = { hosts };
-	end
-	if type(hosts) ~= "table" then
-		return false, "Please supply a host or a list of hosts you would like to see";
-	end
+	hosts = array.collect(set.new({ not hosts and "*" or nil }) + get_hosts_set(hosts)):sort(_sort_hosts);
 
 	local print = self.session.print;
 	for _, host in ipairs(hosts) do