mod_admin_telnet: Factor out function for collecting all c2s sessions for easier reuse
authorKim Alvefur <zash@zash.se>
Fri, 26 Jul 2019 21:05:13 +0200
changeset 10088 e4043e3928f2
parent 10087 f30d505e755b
child 10089 bf51a08a94a7
mod_admin_telnet: Factor out function for collecting all c2s sessions for easier reuse
plugins/mod_admin_telnet.lua
--- a/plugins/mod_admin_telnet.lua	Fri Jul 26 20:25:15 2019 +0200
+++ b/plugins/mod_admin_telnet.lua	Fri Jul 26 21:05:13 2019 +0200
@@ -592,12 +592,16 @@
 	return jid_join("["..ip.."]:"..clientport, session.host or "["..serverip.."]:"..serverport);
 end
 
-local function show_c2s(callback)
+local function get_c2s()
 	local c2s = array.collect(values(prosody.full_sessions));
 	c2s:append(array.collect(values(module:shared"/*/c2s/sessions")));
 	c2s:append(array.collect(values(module:shared"/*/bosh/sessions")));
 	c2s:unique();
-	c2s:sort(function(a, b)
+	return c2s;
+end
+
+local function show_c2s(callback)
+	get_c2s():sort(function(a, b)
 		if a.host == b.host then
 			if a.username == b.username then
 				return (a.resource or "") > (b.resource or "");