comparison mod_invites_page/mod_invites_page.lua @ 4408:2c47b8110c48

mod_invites_page: Some fixes for external-only mode
author Matthew Wild <mwild1@gmail.com>
date Wed, 27 Jan 2021 16:10:08 +0000
parents 85c11eb4331b
children 733e5513f691
comparison
equal deleted inserted replaced
4407:105586ca9a79 4408:2c47b8110c48
1 local st = require "util.stanza"; 1 local st = require "util.stanza";
2 local url_escape = require "util.http".urlencode; 2 local url_escape = require "util.http".urlencode;
3 3
4 module:depends("http"); 4 local base_url = "https://"..module.host.."/";
5 local base_url = module.http_url and module:http_url();
6 5
7 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { 6 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, {
8 urlescape = url_escape; 7 urlescape = url_escape;
9 lower = string.lower; 8 lower = string.lower;
10 classname = function (s) return (s:gsub("%W+", "-")); end; 9 classname = function (s) return (s:gsub("%W+", "-")); end;
20 noscheme = function (url) 19 noscheme = function (url)
21 return (url:gsub("^[^:]+:", "")); 20 return (url:gsub("^[^:]+:", ""));
22 end; 21 end;
23 }); 22 });
24 23
25 module:depends("register_apps");
26
27 local site_name = module:get_option_string("site_name", module.host); 24 local site_name = module:get_option_string("site_name", module.host);
28 local site_apps = module:shared("register_apps/apps"); 25 local site_apps;
29 26
30 -- Enable/disable built-in invite pages 27 -- Enable/disable built-in invite pages
31 local external_only = module:get_option_boolean("invites_page_external", false); 28 local external_only = module:get_option_boolean("invites_page_external", false);
32 29
33 local http_files; 30 local http_files;
34 31
35 if prosody.shutdown then 32 if not external_only then
36 module:depends("http"); 33 -- Load HTTP-serving dependencies
37 http_files = module:depends("http_files"); 34 if prosody.shutdown then -- not if running under prosodyctl
35 module:depends("http");
36 http_files = module:depends("http_files");
37 end
38 -- Calculate automatic base_url default
39 base_url = module.http_url and module:http_url();
40
41 -- Load site apps info
42 module:depends("register_apps");
43 site_apps = module:shared("register_apps/apps");
38 end 44 end
45
39 local invites = module:depends("invites"); 46 local invites = module:depends("invites");
40 47
41 -- Point at eg https://github.com/ge0rg/easy-xmpp-invitation 48 -- Point at eg https://github.com/ge0rg/easy-xmpp-invitation
42 -- This URL must always be absolute, as it is shared standalone 49 -- This URL must always be absolute, as it is shared standalone
43 local invite_url_template = module:get_option_string("invites_page", base_url and (base_url.."?{invite.token}") or nil); 50 local invite_url_template = module:get_option_string("invites_page", base_url and (base_url.."?{invite.token}") or nil);