aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-01-29 18:31:25 +0100
committerKim Alvefur <zash@zash.se>2023-01-29 18:31:25 +0100
commit6e120ad485abaea9a920ba0dad37366188d1570c (patch)
tree19f8b16843c5c4736c30db323d54105e2f5f6a8d
parentd5b5b5ba8651f4ed080fbe4511cce18654a08530 (diff)
downloadprosody-6e120ad485abaea9a920ba0dad37366188d1570c.tar.gz
prosody-6e120ad485abaea9a920ba0dad37366188d1570c.zip
mod_admin_shell: Use tables to present MUC users
Tables are awesome!
-rw-r--r--plugins/mod_admin_shell.lua20
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index 003863fe..1b28029b 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -1401,11 +1401,19 @@ function def_env.muc:occupants(room_jid, filter)
end
local print = self.session.print;
+ local row = format_table({
+ { title = "Role"; width = #"participant"; key = "role" }; -- longest role name
+ { title = "JID"; width = "75%"; key = "bare_jid" };
+ { title = "Nickname"; width = "25%"; key = "nick"; mapper = jid_resource };
+ }, self.session.width);
local total, displayed = 0, 0;
for nick_jid, occupant in room_obj:each_occupant() do
+ if total == 0 then
+ print(row());
+ end
local nick = jid_resource(nick_jid);
if filter == nil or occupant.role == filter or nick:find(filter, 1, true) then
- print(occupant.role, nick);
+ print(row(occupant));
displayed = displayed + 1;
end
total = total + 1
@@ -1425,10 +1433,18 @@ function def_env.muc:affiliations(room_jid, filter)
end
local print = self.session.print;
+ local row = format_table({
+ { title = "Affiliation"; width = #"outcast" }; -- longest affiliation name
+ { title = "JID"; width = "75%" };
+ { title = "Nickname"; width = "25%"; key = "reserved_nickname" };
+ }, self.session.width);
local total, displayed = 0, 0;
for affiliated_jid, affiliation, affiliation_data in room_obj:each_affiliation() do
+ if total == 0 then
+ print(row());
+ end
if filter == nil or affiliation == filter or affiliated_jid:find(filter, 1, true) then
- print(affiliation, affiliated_jid, affiliation_data and affiliation_data.reserved_nickname or "")
+ print(row(setmetatable({ affiliation; affiliated_jid }, { __index = affiliation_data })))
displayed = displayed + 1;
end
total = total + 1