comparison mod_easy_invite/mod_easy_invite.lua @ 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 26559776a87e
children 14028430638b
comparison
equal deleted inserted replaced
3777:26559776a87e 3778:7209f481bcfe
14 local new_adhoc = module:require("adhoc").new; 14 local new_adhoc = module:require("adhoc").new;
15 15
16 -- Whether local users can invite other users to create an account on this server 16 -- Whether local users can invite other users to create an account on this server
17 local allow_user_invites = module:get_option_boolean("allow_user_invites", true); 17 local allow_user_invites = module:get_option_boolean("allow_user_invites", true);
18 18
19 local invites = module:depends("invites"); 19 local invites;
20 if prosody.shutdown then -- COMPAT hack to detect prosodyctl
21 invites = module:depends("invites");
22 end
20 23
21 local invite_result_form = dataforms.new({ 24 local invite_result_form = dataforms.new({
22 title = "Your Invite", 25 title = "Your Invite",
23 -- TODO instructions = something helpful 26 -- TODO instructions = something helpful
24 { 27 {
178 local contact_username = event.username; 181 local contact_username = event.username;
179 182
180 module:log("debug", "Creating mutual subscription between %s and %s", inviter_username, contact_username); 183 module:log("debug", "Creating mutual subscription between %s and %s", inviter_username, contact_username);
181 subscribe_both(module.host, inviter_username, contact_username); 184 subscribe_both(module.host, inviter_username, contact_username);
182 end); 185 end);
186
187
188 local sm = require "core.storagemanager";
189 function module.command(arg)
190 if #arg < 2 then
191 print("usage: prosodyctl mod_easy_invite example.net register");
192 return;
193 end
194
195 local host = arg[1];
196 assert(hosts[host], "Host "..tostring(host).." does not exist");
197 sm.initialize_host(host);
198
199 invites = module:context(host):depends("invites");
200 local invite = invites.create_account();
201 print(invite.uri);
202 end
203