diff 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
line wrap: on
line diff
--- a/mod_invites_register_web/mod_invites_register_web.lua	Thu Oct 01 17:51:32 2020 +0200
+++ b/mod_invites_register_web/mod_invites_register_web.lua	Mon Oct 05 16:45:06 2020 +0100
@@ -1,6 +1,7 @@
 local id = require "util.id";
 local http_formdecode = require "net.http".formdecode;
 local usermanager = require "core.usermanager";
+local modulemanager = require "core.modulemanager";
 local nodeprep = require "util.encodings".stringprep.nodeprep;
 local st = require "util.stanza";
 local url_escape = require "util.http".urlencode;
@@ -14,6 +15,14 @@
 local site_name = module:get_option_string("site_name", module.host);
 local site_apps = module:shared("register_apps/apps");
 
+local webchat_url = module:get_option_string("webchat_url");
+
+-- If not provided, but mod_conversejs is loaded, default to that
+if not webchat_url and modulemanager.get_modules_for_host(module.host):contains("conversejs") then
+	local conversejs = module:depends("conversejs");
+	webchat_url = conversejs.module:http_url();
+end
+
 module:depends("http");
 
 local invites = module:depends("invites");
@@ -166,6 +175,7 @@
 			domain = module.host;
 			password = password;
 			app = app_info;
+			webchat_url = webchat_url;
 		});
 	else
 		local err_id = id.short();