comparison mod_invites_register_web/mod_invites_register_web.lua @ 4167:3a03ae9a0882

mod_invites_register_web: Support linking to a web chat after successful registration
author Matthew Wild <mwild1@gmail.com>
date Mon, 05 Oct 2020 16:45:06 +0100
parents ca099bd28bf5
children e56b6b6852ae
comparison
equal deleted inserted replaced
4166:7678b4880719 4167:3a03ae9a0882
1 local id = require "util.id"; 1 local id = require "util.id";
2 local http_formdecode = require "net.http".formdecode; 2 local http_formdecode = require "net.http".formdecode;
3 local usermanager = require "core.usermanager"; 3 local usermanager = require "core.usermanager";
4 local modulemanager = require "core.modulemanager";
4 local nodeprep = require "util.encodings".stringprep.nodeprep; 5 local nodeprep = require "util.encodings".stringprep.nodeprep;
5 local st = require "util.stanza"; 6 local st = require "util.stanza";
6 local url_escape = require "util.http".urlencode; 7 local url_escape = require "util.http".urlencode;
7 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { 8 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, {
8 urlescape = url_escape; 9 urlescape = url_escape;
11 12
12 module:depends("register_apps"); 13 module:depends("register_apps");
13 14
14 local site_name = module:get_option_string("site_name", module.host); 15 local site_name = module:get_option_string("site_name", module.host);
15 local site_apps = module:shared("register_apps/apps"); 16 local site_apps = module:shared("register_apps/apps");
17
18 local webchat_url = module:get_option_string("webchat_url");
19
20 -- If not provided, but mod_conversejs is loaded, default to that
21 if not webchat_url and modulemanager.get_modules_for_host(module.host):contains("conversejs") then
22 local conversejs = module:depends("conversejs");
23 webchat_url = conversejs.module:http_url();
24 end
16 25
17 module:depends("http"); 26 module:depends("http");
18 27
19 local invites = module:depends("invites"); 28 local invites = module:depends("invites");
20 local invites_page = module:depends("invites_page"); 29 local invites_page = module:depends("invites_page");
164 site_name = site_name; 173 site_name = site_name;
165 username = prepped_username; 174 username = prepped_username;
166 domain = module.host; 175 domain = module.host;
167 password = password; 176 password = password;
168 app = app_info; 177 app = app_info;
178 webchat_url = webchat_url;
169 }); 179 });
170 else 180 else
171 local err_id = id.short(); 181 local err_id = id.short();
172 module:log("warn", "Registration failed (%s): %s", err_id, tostring(err)); 182 module:log("warn", "Registration failed (%s): %s", err_id, tostring(err));
173 return render_html_template(error_template, { 183 return render_html_template(error_template, {