# HG changeset patch # User Matthew Wild # Date 1704729249 0 # Node ID 45d0802d078778f216f6cfad6094c9c69da685a9 # Parent 77c5709bd57a476950c1ee9ef6f5c6ee5dc556bd mod_pubsub_serverinfo: Allow configuration of node persistence/deletion diff -r 77c5709bd57a -r 45d0802d0787 mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua --- a/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Mon Jan 08 15:53:21 2024 +0000 +++ b/mod_pubsub_serverinfo/mod_pubsub_serverinfo.lua Mon Jan 08 15:54:09 2024 +0000 @@ -8,6 +8,8 @@ local actor = module.host .. "/modules/" .. module.name; local publication_interval = module:get_option(module.name .. "_publication_interval") or 300; local cache_ttl = module:get_option(module.name .. "_cache_ttl") or 3600; +local delete_node_on_unload = module:get_option_boolean(module.name.."_delete_node_on_unload", false); +local persist_items = module:get_option_boolean(module.name.."_persist_items", true); local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; @@ -39,7 +41,9 @@ function module.unload() -- This removes all subscribers, which may or may not be desirable, depending on the reason for the unload. - delete_node(); -- Should this block, to delay unload() until the node is deleted? + if delete_node_on_unload then + delete_node(); + end end -- Returns a promise of a boolean @@ -84,7 +88,7 @@ :text_tag("value", "1") :up() :tag("field", { var = "pubsub#persist_items" }) - :text_tag("value", "0") + :text_tag("value", persist_items and "1" or "0") module:log("debug", "Sending request to create pub/sub node '%s' at %s", node, service) return module:send_iq(request):next(