Mercurial > prosody-modules
view mod_pubsub_get/mod_pubsub_get.lua @ 6519:01d8bfbfc435
mod_pubsub_serverinfo: Fix check for local domain
The module was checking whether a host exists, but this may be misleading if
our host is loaded before the host that is being checked.
This change makes it check the config. This will provide a false positive in
the rare case that the host is defined but not activated/enabled. But we don't
have an API currently for "is this host configured and enabled?"
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Tue, 21 Apr 2026 19:54:19 +0100 |
| parents | 119c0eb65bf3 |
| children |
line wrap: on
line source
module:depends("http") local pubsub_service = module:depends("pubsub").service local json = require "util.json" function handle_GET(event) local request, response = event.request, event.response local query = request.url.query if query:sub(1, 5) ~= "node=" then return 400 end local node = query:sub(6) local ok, items = pubsub_service:get_items(node, true) if not ok then return 404 end response.status_code = 200 return json.encode(items) end module:provides("http", {route = {GET = handle_GET}})
