# HG changeset patch # User Kim Alvefur # Date 1589651306 -7200 # Node ID 3ac31ddab7eb1d547ae23c138477843f400b8857 # Parent 1925d63eec6bc5ab09b6021610e0be6de8099be2 mod_easy_invite: Add commands to telnet console Handy if all you have is SSH access and no ad-hoc capable client diff -r 1925d63eec6b -r 3ac31ddab7eb mod_easy_invite/mod_easy_invite.lua --- a/mod_easy_invite/mod_easy_invite.lua Sat May 16 18:30:01 2020 +0200 +++ b/mod_easy_invite/mod_easy_invite.lua Sat May 16 19:48:26 2020 +0200 @@ -184,6 +184,35 @@ subscribe_both(module.host, inviter_username, contact_username); end); +do + -- Telnet command + -- Since the telnet console is global this overwrites the command for + -- each host it's loaded on, but this should be fine. + + local get_module = require "core.modulemanager".get_module; + + local console_env = module:shared("/*/admin_telnet/env"); + + -- luacheck: ignore 212/self + console_env.invite = {}; + function console_env.invite:create_account(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); + if not invite then return nil, err; end + return true, invite.uri; + end + + function console_env.invite:create_contact(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); + if not invite then return nil, err; end + return true, invite.uri; + end +end local sm = require "core.storagemanager"; function module.command(arg)