Mercurial > prosody-modules
diff mod_pubsub_text_interface/mod_pubsub_text_interface.lua @ 3488:4ddb034a8a03
mod_pubsub_text_interface: Add command for listing current subscriptions
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 15 Mar 2019 04:26:54 +0100 |
parents | 1f0c290bd28a |
children | 33b3f02a9e7d |
line wrap: on
line diff
--- a/mod_pubsub_text_interface/mod_pubsub_text_interface.lua Thu Mar 14 01:26:54 2019 +0100 +++ b/mod_pubsub_text_interface/mod_pubsub_text_interface.lua Fri Mar 15 04:26:54 2019 +0100 @@ -11,6 +11,7 @@ - `help` - this help message - `list` - list available nodes +- `subscriptions` - list nodes you are subscribed to - `subscribe node` - subscribe to a node - `unsubscribe node` - unsubscribe from a node]]; if pubsub.get_last_item then -- COMPAT not available in 0.10 @@ -43,6 +44,19 @@ else reply:body(nodes); end + elseif command == "subscriptions" then + local ok, subs = pubsub:get_subscriptions(nil, from, from); + if not ok then + reply:body(subs); + elseif #subs == 0 then + reply:body("You are not subscribed to anything from this pubsub service"); + else + local response = {}; + for i = 1, #subs do + response[i] = string.format("- `%s`", subs[i].node); + end + reply:body(table.concat(response, "\n")); + end elseif command == "subscribe" then local ok, err = pubsub:add_subscription(node_arg, from, jid.bare(from), { ["pubsub#include_body"] = true }); reply:body(ok and "OK" or err);