Mercurial > prosody-hg
comparison plugins/mod_pubsub/commands.lib.lua @ 14033:fe024a5be7e6 13.0
mod_pubsub/commands: Fix listing item numbers along with item names
The get_items method returns a table where integer keys carry the order
of items, while string keys carry item data, like { [1] = "item", ["item"] = {} }
The command should only print the item names, not the integer keys.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 12 Jan 2026 06:47:50 +0100 |
| parents | e226f9632a48 |
| children |
comparison
equal
deleted
inserted
replaced
| 14028:04d7f2038933 | 14033:fe024a5be7e6 |
|---|---|
| 42 -- luacheck: ignore 431/service | 42 -- luacheck: ignore 431/service |
| 43 local service = get_service(service_jid); | 43 local service = get_service(service_jid); |
| 44 local items = select(2, assert(service:get_items(node_name, true))); | 44 local items = select(2, assert(service:get_items(node_name, true))); |
| 45 | 45 |
| 46 local count = 0; | 46 local count = 0; |
| 47 for item_name in pairs(items) do | 47 for _, item_name in ipairs(items) do |
| 48 count = count + 1; | 48 count = count + 1; |
| 49 self.session.print(item_name); | 49 self.session.print(item_name); |
| 50 end | 50 end |
| 51 return true, ("%d items"):format(count); | 51 return true, ("%d items"):format(count); |
| 52 end; | 52 end; |
