Software /
code /
prosody
Diff
plugins/mod_pubsub.lua @ 3641:3603aeb325de
mod_pubsub, util.pubsub: Support for fetching items
author | Florian Zeitz <florob@babelmonkeys.de> |
---|---|
date | Thu, 25 Nov 2010 21:47:12 +0100 |
parent | 3622:418354197a02 |
child | 3672:b24db47995ac |
line wrap: on
line diff
--- a/plugins/mod_pubsub.lua Fri Nov 26 05:26:12 2010 +0500 +++ b/plugins/mod_pubsub.lua Thu Nov 25 21:47:12 2010 +0100 @@ -37,6 +37,24 @@ return reply; end +function handlers.get_items(origin, stanza, items) + local node = items.attr.node; + local item = items:get_child("item"); + local id = item and item.attr.id; + local data = st.stanza("items", { node = node }); + for _, entry in pairs(service:get(node, stanza.attr.from, id)) do + data:add_child(entry); + end + if data then + reply = st.reply(stanza) + :tag("pubsub", { xmlns = xmlns_pubsub }) + :add_child(data); + else + reply = st.error_reply(stanza, "cancel", "item-not-found", "Item could not be found in this node"); + end + return origin.send(reply); +end + function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; if jid_bare(jid) ~= jid_bare(stanza.attr.from) then