# HG changeset patch # User Matthew Wild # Date 1577444443 0 # Node ID 7209f481bcfe5464c48cc0b55451a50d0bf5253a # Parent 26559776a87e5966f0f866aad232aaffe805bfd4 mod_easy_invite: Add prosodyctl command to generate account invites diff -r 26559776a87e -r 7209f481bcfe mod_easy_invite/README.markdown --- a/mod_easy_invite/README.markdown Fri Dec 27 10:41:01 2019 +0000 +++ b/mod_easy_invite/README.markdown Fri Dec 27 11:00:43 2019 +0000 @@ -26,6 +26,16 @@ contact invites, but new contacts will be required to register an account on a different server. +# Usage + +Users can use the "New Invite" ad-hoc command through their client. + +Admins can create registration links using prosodyctl, e.g. + +``` +prosodyctl mod_easy_invite example.com register +``` + # Compatibility 0.11 and later. diff -r 26559776a87e -r 7209f481bcfe mod_easy_invite/mod_easy_invite.lua --- a/mod_easy_invite/mod_easy_invite.lua Fri Dec 27 10:41:01 2019 +0000 +++ b/mod_easy_invite/mod_easy_invite.lua Fri Dec 27 11:00:43 2019 +0000 @@ -16,7 +16,10 @@ -- Whether local users can invite other users to create an account on this server local allow_user_invites = module:get_option_boolean("allow_user_invites", true); -local invites = module:depends("invites"); +local invites; +if prosody.shutdown then -- COMPAT hack to detect prosodyctl + invites = module:depends("invites"); +end local invite_result_form = dataforms.new({ title = "Your Invite", @@ -180,3 +183,21 @@ module:log("debug", "Creating mutual subscription between %s and %s", inviter_username, contact_username); subscribe_both(module.host, inviter_username, contact_username); end); + + +local sm = require "core.storagemanager"; +function module.command(arg) + if #arg < 2 then + print("usage: prosodyctl mod_easy_invite example.net register"); + return; + end + + local host = arg[1]; + assert(hosts[host], "Host "..tostring(host).." does not exist"); + sm.initialize_host(host); + + invites = module:context(host):depends("invites"); + local invite = invites.create_account(); + print(invite.uri); +end +