diff options
author | Matthew Wild <mwild1@gmail.com> | 2025-01-07 14:27:18 +0000 |
---|---|---|
committer | Matthew Wild <mwild1@gmail.com> | 2025-01-07 14:27:18 +0000 |
commit | a10a0140e5256b0060fb5633f89394aeebcf07b6 (patch) | |
tree | 7d783069272890de7ac107acbd657e44c9cc9e9d /plugins/mod_pubsub/mod_pubsub.lua | |
parent | 0d15dab13fa83084f801b8f50eb1a34994598ebc (diff) | |
download | prosody-a10a0140e5256b0060fb5633f89394aeebcf07b6.tar.gz prosody-a10a0140e5256b0060fb5633f89394aeebcf07b6.zip |
mod_pubsub: Expand shell commands to include node/item management
Diffstat (limited to 'plugins/mod_pubsub/mod_pubsub.lua')
-rw-r--r-- | plugins/mod_pubsub/mod_pubsub.lua | 39 |
1 files changed, 1 insertions, 38 deletions
diff --git a/plugins/mod_pubsub/mod_pubsub.lua b/plugins/mod_pubsub/mod_pubsub.lua index c17d9e63..54382712 100644 --- a/plugins/mod_pubsub/mod_pubsub.lua +++ b/plugins/mod_pubsub/mod_pubsub.lua @@ -274,41 +274,4 @@ local function get_service(service_jid) return assert(assert(prosody.hosts[service_jid], "Unknown pubsub service").modules.pubsub, "Not a pubsub service").service; end -module:add_item("shell-command", { - section = "pubsub"; - section_desc = "Manage publish/subscribe nodes"; - name = "create_node"; - desc = "Create a node with the specified name"; - args = { - { name = "service_jid", type = "string" }; - { name = "node_name", type = "string" }; - }; - host_selector = "service_jid"; - - handler = function (self, service_jid, node_name) --luacheck: ignore 212/self - return get_service(service_jid):create(node_name, true); - end; -}); - -module:add_item("shell-command", { - section = "pubsub"; - section_desc = "Manage publish/subscribe nodes"; - name = "list_nodes"; - desc = "List nodes on a pubsub service"; - args = { - { name = "service_jid", type = "string" }; - }; - host_selector = "service_jid"; - - handler = function (self, service_jid) --luacheck: ignore 212/self - -- luacheck: ignore 431/service - local service = get_service(service_jid); - local nodes = select(2, assert(service:get_nodes(true))); - local count = 0; - for node_name in pairs(nodes) do - count = count + 1; - self.session.print(node_name); - end - return true, ("%d nodes"):format(count); - end; -}); +module:require("commands").add_commands(get_service); |