comparison mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua @ 5843:79ae71f52c81

mod_pubsub_serverinfo: Update to use mod_server_info (fixes #1841) ...but only for Prosody trunk users, because 0.12 mod_server_contact_info does not use the new API in mod_server_info.
author Matthew Wild <mwild1@gmail.com>
date Fri, 23 Feb 2024 22:50:57 +0000
parents 7905766d01f6
children 49b0873932ca
comparison
equal deleted inserted replaced
5842:ed82916e5796 5843:79ae71f52c81
1 local http = require "net.http"; 1 local http = require "net.http";
2 local json = require "util.json"; 2 local json = require "util.json";
3 local st = require "util.stanza"; 3 local st = require "util.stanza";
4 local new_id = require"util.id".medium; 4 local new_id = require"util.id".medium;
5 local dataform = require "util.dataforms".new;
6 5
7 local local_domain = module:get_host(); 6 local local_domain = module:get_host();
8 local service = module:get_option(module.name .. "_service") or "pubsub." .. local_domain; 7 local service = module:get_option(module.name .. "_service") or "pubsub." .. local_domain;
9 local node = module:get_option(module.name .. "_node") or "serverinfo"; 8 local node = module:get_option(module.name .. "_node") or "serverinfo";
10 local actor = module.host .. "/modules/" .. module.name; 9 local actor = module.host .. "/modules/" .. module.name;
27 end 26 end
28 ) 27 )
29 28
30 module:add_feature("urn:xmpp:serverinfo:0"); 29 module:add_feature("urn:xmpp:serverinfo:0");
31 30
32 module:add_extension(dataform { 31 module:add_item("server-info-fields", {
33 { name = "FORM_TYPE", type = "hidden", value = "http://jabber.org/network/serverinfo" }, 32 { name = "serverinfo-pubsub-node", type = "text-single", value = ("xmpp:%s?;node=%s"):format(service, node) };
34 { name = "serverinfo-pubsub-node", type = "text-single" }, 33 });
35 }:form({ ["serverinfo-pubsub-node"] = ("xmpp:%s?;node=%s"):format(service, node) }, "result"));
36 34
37 if cache_ttl < publication_interval then 35 if cache_ttl < publication_interval then
38 module:log("warn", "It is recommended to have a cache interval higher than the publication interval"); 36 module:log("warn", "It is recommended to have a cache interval higher than the publication interval");
39 end 37 end
40 38