aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2021-11-10 15:54:27 +0100
committerKim Alvefur <zash@zash.se>2021-11-10 15:54:27 +0100
commitaef0454598667638bac970b91f25833c29bde82b (patch)
tree2fe8cc1ec814809afc593860eadfd5bebe59c4ff /plugins
parent29535c322af6d151f085bc6e6e0c888b88a813c9 (diff)
downloadprosody-aef0454598667638bac970b91f25833c29bde82b.tar.gz
prosody-aef0454598667638bac970b91f25833c29bde82b.zip
mod_admin_shell: Optionally group session listings by host when not included as column
Similar to the earlier view
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_shell.lua36
1 files changed, 33 insertions, 3 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index 62906ec0..7bff4ef3 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -833,9 +833,24 @@ function def_env.c2s:show(match_jid, colspec)
return (not match_jid) or jid:match(match_jid)
end
- print(row());
+ local group_by_host = true;
+ for _, col in ipairs(columns) do
+ if col.key == "full_jid" or col.key == "host" then
+ group_by_host = false;
+ break
+ end
+ end
+
+ if not group_by_host then print(row()); end
+ local currenthost = nil;
for _, session in ipairs(get_c2s():filter(match):sort(_sort_by_jid)) do
+ if group_by_host and session.host ~= currenthost then
+ currenthost = session.host;
+ print("#",prosody.hosts[currenthost] or "Unknown host");
+ print(row());
+ end
+
print(row(session));
end
return true;
@@ -894,11 +909,26 @@ function def_env.s2s:show(match_jid, colspec)
return not match_jid or (host or ""):match(match_jid) or (remote or ""):match(match_jid);
end
- local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")):filter(match):sort(_sort_s2s);
+ local group_by_host = true;
+ local currenthost = nil;
+ for _, col in ipairs(columns) do
+ if col.key == "host" then
+ group_by_host = false;
+ break
+ end
+ end
+
+ if not group_by_host then print(row()); end
- print(row());
+ local s2s_sessions = array(iterators.values(module:shared"/*/s2s/sessions")):filter(match):sort(_sort_s2s);
for _, session in ipairs(s2s_sessions) do
+ if group_by_host and currenthost ~= get_s2s_hosts(session) then
+ currenthost = get_s2s_hosts(session);
+ print("#",prosody.hosts[currenthost] or "Unknown host");
+ print(row());
+ end
+
print(row(session));
end
return true; -- TODO counts