# HG changeset patch # User Trần H. Trung # Date 1690628938 -25200 # Node ID 758866b43aa4cc832e619d17d49232fc76c228f5 # Parent 160868fdddd6353820bd075487cb41392ec10d67 mod_webpresence: use module:http_url() to get the correct url. diff -r 160868fdddd6 -r 758866b43aa4 mod_webpresence/mod_webpresence.lua --- a/mod_webpresence/mod_webpresence.lua Thu Jul 27 18:41:06 2023 +0700 +++ b/mod_webpresence/mod_webpresence.lua Sat Jul 29 18:08:58 2023 +0700 @@ -58,21 +58,23 @@ }; }; -local function webpresence_url(jid_bare) - local config, path = module:get_option("http_paths"); +local function webpresence_url(jid) + local path = "/status"; + local config = module:get_option("http_paths"); if config then for k, v in pairs(config) do - if k == moduleName then path = v; - else path = "/status" .. "/"; end + if k == moduleName then + path = v; + break; + end end - else path = "/status" .. "/"; end + end - local urlConfig = module:get_option_string("http_external_link"); - local urlBase = urlConfig..path..jid_bare; - local style = { "/text", "/message", "/json", "/html" }; - local urlResult = urlBase.."\n"; + local urlBase = module:context(module.host):http_url(module.name, path); + local style = { "text", "message", "json", "html" }; + local urlResult = urlBase.."/"..jid.."\n"; for _, v in ipairs(style) do - urlResult = urlResult..urlBase..v.."\n"; + urlResult = urlResult..urlBase.."/"..jid.."/"..v.."\n"; end return urlResult; end @@ -110,7 +112,7 @@ else local resultSet, resultErr = webpresence_set(user, newValue) if not resultSet or resultErr then - module:log(error, "Could not set value: %s", errOut); + module:log("error", moduleName..": ".."Could not set value for "..user.."@"..host..": %s", errOut); return { status = "completed"; info = "Could not set value: "..tostring(data.from).." …\n"