Software /
code /
prosody-modules
Changeset
3778:7209f481bcfe
mod_easy_invite: Add prosodyctl command to generate account invites
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 27 Dec 2019 11:00:43 +0000 |
parents | 3777:26559776a87e |
children | 3779:5e69a4358053 |
files | mod_easy_invite/README.markdown mod_easy_invite/mod_easy_invite.lua |
diffstat | 2 files changed, 32 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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.
--- 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 +