aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2023-11-29 17:34:44 +0000
committerMatthew Wild <mwild1@gmail.com>2023-11-29 17:34:44 +0000
commitd200b57cfe3d3e1176b0411a5337ee1bf4f34088 (patch)
treecd2ba80b856f1af2c05f66b56fc509dcdfd39e69 /plugins
parent44aea8f4f5269ef9cd2f6d2d8c8d20c20f7c5ac0 (diff)
downloadprosody-d200b57cfe3d3e1176b0411a5337ee1bf4f34088.tar.gz
prosody-d200b57cfe3d3e1176b0411a5337ee1bf4f34088.zip
mod_invites: Use new shell-command API
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_invites.lua47
1 files changed, 25 insertions, 22 deletions
diff --git a/plugins/mod_invites.lua b/plugins/mod_invites.lua
index 14f710c7..d31e8bfc 100644
--- a/plugins/mod_invites.lua
+++ b/plugins/mod_invites.lua
@@ -202,34 +202,37 @@ function use(token) --luacheck: ignore 131/use
end
--- shell command
-do
- -- Since the console is global this overwrites the command for
- -- each host it's loaded on, but this should be fine.
-
- local get_module = require "prosody.core.modulemanager".get_module;
-
- local console_env = module:shared("/*/admin_shell/env");
-
- -- luacheck: ignore 212/self
- console_env.invite = {};
- function console_env.invite:create_account(user_jid)
+module:add_item("shell-command", {
+ section = "invite";
+ section_desc = "Create and manage invitations";
+ name = "create_account";
+ desc = "Create an invitation to make an account on this server with the specified JID (supply only a hostname to allow any username)";
+ args = { { name = "user_jid", type = "string" } };
+ host_selector = "user_jid";
+
+ handler = function (self, user_jid)
local username, host = jid_split(user_jid);
- local mod_invites, err = get_module(host, "invites");
- if not mod_invites then return nil, err or "mod_invites not loaded on this host"; end
- local invite, err = mod_invites.create_account(username);
+ local invite, err = create_account(username);
if not invite then return nil, err; end
return true, invite.landing_page or invite.uri;
- end
-
- function console_env.invite:create_contact(user_jid, allow_registration)
+ end;
+});
+
+module:add_item("shell-command", {
+ section = "invite";
+ section_desc = "Create and manage invitations";
+ name = "create_contact";
+ desc = "Create an invitation to become contacts with the specified user";
+ args = { { name = "user_jid", type = "string" }, { name = "allow_registration" } };
+ host_selector = "user_jid";
+
+ handler = function (self, user_jid, allow_registration)
local username, host = jid_split(user_jid);
- local mod_invites, err = get_module(host, "invites");
- if not mod_invites then return nil, err or "mod_invites not loaded on this host"; end
- local invite, err = mod_invites.create_contact(username, allow_registration);
+ local invite, err = create_contact(username, allow_registration);
if not invite then return nil, err; end
return true, invite.landing_page or invite.uri;
- end
-end
+ end;
+});
local subcommands = {};