aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2023-01-29 17:55:56 +0100
committerKim Alvefur <zash@zash.se>2023-01-29 17:55:56 +0100
commitd5b5b5ba8651f4ed080fbe4511cce18654a08530 (patch)
treefabab50ed7279787b6298ef13ecec97e3e72bd54 /plugins
parent08a730746ce2dc52d2bc47d9868d64f601e2ea81 (diff)
downloadprosody-d5b5b5ba8651f4ed080fbe4511cce18654a08530.tar.gz
prosody-d5b5b5ba8651f4ed080fbe4511cce18654a08530.zip
mod_admin_shell: Factor out room retrieval into common function
Justification: See diffstat
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_admin_shell.lua36
1 files changed, 18 insertions, 18 deletions
diff --git a/plugins/mod_admin_shell.lua b/plugins/mod_admin_shell.lua
index e4ebe4c4..003863fe 100644
--- a/plugins/mod_admin_shell.lua
+++ b/plugins/mod_admin_shell.lua
@@ -1349,6 +1349,18 @@ local function check_muc(jid)
return room_name, host;
end
+local function get_muc(room_jid)
+ local room_name, host = check_muc(room_jid);
+ if not room_name then
+ return room_name, host;
+ end
+ 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
+ return room_obj;
+end
+
function def_env.muc:create(room_jid, config)
local room_name, host = check_muc(room_jid);
if not room_name then
@@ -1361,13 +1373,9 @@ function def_env.muc:create(room_jid, config)
end
function def_env.muc:room(room_jid)
- local room_name, host = check_muc(room_jid);
- if not room_name then
- return room_name, host;
- end
- local room_obj = prosody.hosts[host].modules.muc.get_room_from_jid(room_jid);
+ local room_obj, err = get_muc(room_jid);
if not room_obj then
- return nil, "No such room: "..room_jid;
+ return room_obj, err;
end
return setmetatable({ room = room_obj }, console_room_mt);
end
@@ -1387,13 +1395,9 @@ function def_env.muc:list(host)
end
function def_env.muc:occupants(room_jid, filter)
- local room_name, host = check_muc(room_jid);
- if not room_name then
- return room_name, host;
- end
- local room_obj = prosody.hosts[host].modules.muc.get_room_from_jid(room_jid);
+ local room_obj, err = get_muc(room_jid);
if not room_obj then
- return nil, "No such room: " .. room_jid;
+ return room_obj, err;
end
local print = self.session.print;
@@ -1415,13 +1419,9 @@ function def_env.muc:occupants(room_jid, filter)
end
function def_env.muc:affiliations(room_jid, filter)
- local room_name, host = check_muc(room_jid);
- if not room_name then
- return room_name, host;
- end
- local room_obj = prosody.hosts[host].modules.muc.get_room_from_jid(room_jid);
+ local room_obj, err = get_muc(room_jid);
if not room_obj then
- return nil, "No such room: " .. room_jid;
+ return room_obj, err;
end
local print = self.session.print;