Mercurial > prosody-modules
comparison mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua @ 5815:77c5709bd57a
mod_pubsub_serverinfo: Add explicit xmlns to all pubsub tags
This helps when routing between hosts on the same server, where the namespace
normalization is not handled by default.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Mon, 08 Jan 2024 15:53:21 +0000 |
parents | fa28fc2ee465 |
children | 45d0802d0787 |
comparison
equal
deleted
inserted
replaced
5814:fa28fc2ee465 | 5815:77c5709bd57a |
---|---|
7 local node = module:get_option(module.name .. "_node") or "serverinfo"; | 7 local node = module:get_option(module.name .. "_node") or "serverinfo"; |
8 local actor = module.host .. "/modules/" .. module.name; | 8 local actor = module.host .. "/modules/" .. module.name; |
9 local publication_interval = module:get_option(module.name .. "_publication_interval") or 300; | 9 local publication_interval = module:get_option(module.name .. "_publication_interval") or 300; |
10 local cache_ttl = module:get_option(module.name .. "_cache_ttl") or 3600; | 10 local cache_ttl = module:get_option(module.name .. "_cache_ttl") or 3600; |
11 | 11 |
12 local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; | |
12 | 13 |
13 function module.load() | 14 function module.load() |
14 discover_node():next( | 15 discover_node():next( |
15 function(exists) | 16 function(exists) |
16 if not exists then create_node() end | 17 if not exists then create_node() end |
70 end | 71 end |
71 | 72 |
72 -- Returns a promise of a boolean | 73 -- Returns a promise of a boolean |
73 function create_node() | 74 function create_node() |
74 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) | 75 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) |
75 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) | 76 :tag("pubsub", { xmlns = xmlns_pubsub }) |
76 :tag("create", { node = node }):up() | 77 :tag("create", { node = node, xmlns = xmlns_pubsub }):up() |
77 :tag("configure") | 78 :tag("configure", { xmlns = xmlns_pubsub }) |
78 :tag("x", { xmlns = "jabber:x:data", type = "submit" }) | 79 :tag("x", { xmlns = "jabber:x:data", type = "submit" }) |
79 :tag("field", { var = "FORM_TYPE", type = "hidden"}) | 80 :tag("field", { var = "FORM_TYPE", type = "hidden"}) |
80 :text_tag("value", "http://jabber.org/protocol/pubsub#node_config") | 81 :text_tag("value", "http://jabber.org/protocol/pubsub#node_config") |
81 :up() | 82 :up() |
82 :tag("field", { var = "pubsub#max_items" }) | 83 :tag("field", { var = "pubsub#max_items" }) |
100 end | 101 end |
101 | 102 |
102 -- Returns a promise of a boolean | 103 -- Returns a promise of a boolean |
103 function delete_node() | 104 function delete_node() |
104 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) | 105 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) |
105 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) | 106 :tag("pubsub", { xmlns = xmlns_pubsub }) |
106 :tag("delete", { node = node }); | 107 :tag("delete", { node = node, xmlns = xmlns_pubsub }); |
107 | 108 |
108 module:log("debug", "Sending request to delete pub/sub node '%s' at %s", node, service) | 109 module:log("debug", "Sending request to delete pub/sub node '%s' at %s", node, service) |
109 return module:send_iq(request):next( | 110 return module:send_iq(request):next( |
110 function(response) | 111 function(response) |
111 if response.stanza == nil or response.stanza.attr.type ~= "result" then | 112 if response.stanza == nil or response.stanza.attr.type ~= "result" then |
171 module:log("debug", "Publishing server info..."); | 172 module:log("debug", "Publishing server info..."); |
172 local domains_by_host = get_remote_domain_names() | 173 local domains_by_host = get_remote_domain_names() |
173 | 174 |
174 -- Build the publication stanza. | 175 -- Build the publication stanza. |
175 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) | 176 local request = st.iq({ type = "set", to = service, from = actor, id = new_id() }) |
176 :tag("pubsub", { xmlns = "http://jabber.org/protocol/pubsub" }) | 177 :tag("pubsub", { xmlns = xmlns_pubsub }) |
177 :tag("publish", { node = node, xmlns = "http://jabber.org/protocol/pubsub" }) | 178 :tag("publish", { node = node, xmlns = xmlns_pubsub }) |
178 :tag("item", { id = "current", xmlns = "http://jabber.org/protocol/pubsub" }) | 179 :tag("item", { id = "current", xmlns = xmlns_pubsub }) |
179 :tag("serverinfo", { xmlns = "urn:xmpp:serverinfo:0" }) | 180 :tag("serverinfo", { xmlns = "urn:xmpp:serverinfo:0" }) |
180 | 181 |
181 request:tag("domain", { name = local_domain }) | 182 request:tag("domain", { name = local_domain }) |
182 :tag("federation") | 183 :tag("federation") |
183 | 184 |