aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_admin_adhoc.lua
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/mod_admin_adhoc.lua')
-rw-r--r--plugins/mod_admin_adhoc.lua60
1 files changed, 35 insertions, 25 deletions
diff --git a/plugins/mod_admin_adhoc.lua b/plugins/mod_admin_adhoc.lua
index f3de6793..37e77ab0 100644
--- a/plugins/mod_admin_adhoc.lua
+++ b/plugins/mod_admin_adhoc.lua
@@ -3,6 +3,7 @@
-- This file is MIT/X11 licensed. Please see the
-- COPYING file in the source package for more information.
--
+-- luacheck: ignore 212/self 212/data 212/state 412/err 422/err
local _G = _G;
@@ -95,7 +96,12 @@ local change_user_password_command_handler = adhoc_simple(change_user_password_l
end
local username, host, resource = jid.split(fields.accountjid);
if module_host ~= host then
- return { status = "completed", error = { message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. module_host}};
+ return {
+ status = "completed",
+ error = {
+ message = "Trying to change the password of a user on " .. host .. " but command was sent to " .. module_host
+ }
+ };
end
if usermanager_user_exists(username, host) and usermanager_set_password(username, fields.password, host, nil) then
return { status = "completed", info = "Password successfully changed" };
@@ -207,8 +213,8 @@ local get_user_password_handler = adhoc_simple(get_user_password_layout, functio
return generate_error_message(err);
end
local user, host, resource = jid.split(fields.accountjid);
- local accountjid = "";
- local password = "";
+ local accountjid;
+ local password;
if host ~= module_host then
return { status = "completed", error = { message = "Tried to get password for a user on " .. host .. " but command was sent to " .. module_host } };
elseif usermanager_user_exists(user, host) then
@@ -246,15 +252,15 @@ local get_user_roster_handler = adhoc_simple(get_user_roster_layout, function(fi
local roster = rm_load_roster(user, host);
local query = st.stanza("query", { xmlns = "jabber:iq:roster" });
- for jid in pairs(roster) do
- if jid then
+ for contact_jid in pairs(roster) do
+ if contact_jid then
query:tag("item", {
- jid = jid,
- subscription = roster[jid].subscription,
- ask = roster[jid].ask,
- name = roster[jid].name,
+ jid = contact_jid,
+ subscription = roster[contact_jid].subscription,
+ ask = roster[contact_jid].ask,
+ name = roster[contact_jid].name,
});
- for group in pairs(roster[jid].groups) do
+ for group in pairs(roster[contact_jid].groups) do
query:tag("group"):text(group):up();
end
query:up();
@@ -289,7 +295,7 @@ local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fiel
return generate_error_message(err);
end
- local user, host, resource = jid.split(fields.accountjid);
+ local user, host = jid.split(fields.accountjid);
if host ~= module_host then
return { status = "completed", error = { message = "Tried to get stats for a user on " .. host .. " but command was sent to " .. module_host } };
elseif not usermanager_user_exists(user, host) then
@@ -299,8 +305,8 @@ local get_user_stats_handler = adhoc_simple(get_user_stats_layout, function(fiel
local rostersize = 0;
local IPs = "";
local resources = "";
- for jid in pairs(roster) do
- if jid then
+ for contact_jid in pairs(roster) do
+ if contact_jid then
rostersize = rostersize + 1;
end
end
@@ -319,7 +325,7 @@ local get_online_users_layout = dataforms_new{
{ name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" };
{ name = "max_items", type = "list-single", label = "Maximum number of users",
- value = { "25", "50", "75", "100", "150", "200", "all" } };
+ options = { "25", "50", "75", "100", "150", "200", "all" } };
{ name = "details", type = "boolean", label = "Show details" };
};
@@ -369,7 +375,7 @@ local list_s2s_this_result = dataforms_new {
{ name = "FORM_TYPE", type = "hidden", value = "http://prosody.im/protocol/s2s#list" };
{ name = "sessions", type = "text-multi", label = "Connections:" };
- { name = "num_in", type = "text-single", label = "#incomming connections:" };
+ { name = "num_in", type = "text-single", label = "#incoming connections:" };
{ name = "num_out", type = "text-single", label = "#outgoing connections:" };
};
@@ -588,7 +594,7 @@ end, function(fields, err)
end
local ok_list, err_list = {}, {};
- for host_name, host in pairs(hosts) do
+ for host_name in pairs(hosts) do
if modulemanager.is_loaded(host_name, fields.module) then
local ok, err = modulemanager.reload(host_name, fields.module);
if ok then
@@ -641,13 +647,16 @@ local shut_down_service_layout = dataforms_new{
{ name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/protocol/admin" };
{ name = "delay", type = "list-single", label = "Time delay before shutting down",
- value = { {label = "30 seconds", value = "30"},
- {label = "60 seconds", value = "60"},
- {label = "90 seconds", value = "90"},
- {label = "2 minutes", value = "120"},
- {label = "3 minutes", value = "180"},
- {label = "4 minutes", value = "240"},
- {label = "5 minutes", value = "300"},
+ value = "5",
+ options = {
+ {label = "5 seconds", value = "5"},
+ {label = "30 seconds", value = "30"},
+ {label = "60 seconds", value = "60"},
+ {label = "90 seconds", value = "90"},
+ {label = "2 minutes", value = "120"},
+ {label = "3 minutes", value = "180"},
+ {label = "4 minutes", value = "240"},
+ {label = "5 minutes", value = "300"},
};
};
{ name = "announcement", type = "text-multi", label = "Announcement" };
@@ -664,7 +673,7 @@ local shut_down_service_handler = adhoc_simple(shut_down_service_layout, functio
send_to_online(message);
end
- timer_add_task(tonumber(fields.delay or "5"), function(time) prosody.shutdown("Shutdown by adhoc command") end);
+ timer_add_task(tonumber(fields.delay or "5"), function() prosody.shutdown("Shutdown by adhoc command") end);
return { status = "completed", info = "Server is about to shut down" };
end);
@@ -730,7 +739,7 @@ end, function(fields, err)
end
local ok_list, err_list = {}, {};
- for host_name, host in pairs(hosts) do
+ for host_name in pairs(hosts) do
if modulemanager.is_loaded(host_name, fields.module) then
local ok, err = modulemanager.unload(host_name, fields.module);
if ok then
@@ -799,6 +808,7 @@ local deactivate_host_handler = adhoc_simple(deactivate_host_layout, function(fi
end
end);
+-- luacheck: max_line_length 180
local add_user_desc = adhoc_new("Add User", "http://jabber.org/protocol/admin#add-user", add_user_command_handler, "admin");
local change_user_password_desc = adhoc_new("Change User Password", "http://jabber.org/protocol/admin#change-user-password", change_user_password_command_handler, "admin");