Diff

mod_invites_api/mod_invites_api.lua @ 5628:a74b07764d3f

mod_invites_api: use the nice `module:http_url()` to get the correct url.
author Trần H. Trung <xmpp:trần.h.trung@trung.fun>
date Thu, 27 Jul 2023 18:33:12 +0700
parent 5595:f7410850941f
child 5629:160868fdddd6
line wrap: on
line diff
--- a/mod_invites_api/mod_invites_api.lua	Wed Jul 26 18:45:41 2023 +0700
+++ b/mod_invites_api/mod_invites_api.lua	Thu Jul 27 18:33:12 2023 +0700
@@ -10,7 +10,7 @@
 -- on the server, use the option above instead.
 local allow_contact_invites = module:get_option_boolean("allow_contact_invites", true);
 
-local api_key_store, api_key_store_kv, invites, date, config, path;
+local api_key_store, api_key_store_kv, invites, date, config, path, url_base;
 -- COMPAT: workaround to avoid executing inside prosodyctl
 if prosody.shutdown then
 	module:depends("http");
@@ -108,20 +108,8 @@
 end
 
 local function get_url(id, token)
-	local config, path = module:get_option("http_paths");
-	if config then
-		for k, v in pairs(config) do
-			if k == module.name then 
-				path = v;
-				break;
-			else 
-				path = "/"..module.name;
-			end
-		end
-	else path = "/"..module.name ; end
-
-	local url_base = module:get_option_string("http_external_link", module.host);
-	return url_base..path.."?key="..id.."/"..token.."&redirect=true";
+	local url_base = module:context(module.host):http_url(module.name, "/"..module.name);
+	return url_base.."?key="..id.."/"..token.."&redirect=true";
 end
 
 function module.command(arg)