aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/mod_pubsub.lua
diff options
context:
space:
mode:
authorFlorian Zeitz <florob@babelmonkeys.de>2010-11-25 21:47:12 +0100
committerFlorian Zeitz <florob@babelmonkeys.de>2010-11-25 21:47:12 +0100
commite058268edaa505532bee611459b253ec000df841 (patch)
tree732bc453b22be4c0ada959fab5b4438ea7cc6f45 /plugins/mod_pubsub.lua
parent8dd8338afca7afefbb6921a71d399bf1513f3e05 (diff)
downloadprosody-e058268edaa505532bee611459b253ec000df841.tar.gz
prosody-e058268edaa505532bee611459b253ec000df841.zip
mod_pubsub, util.pubsub: Support for fetching items
Diffstat (limited to 'plugins/mod_pubsub.lua')
-rw-r--r--plugins/mod_pubsub.lua18
1 files changed, 18 insertions, 0 deletions
diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua
index cb0eff7a..da2070f3 100644
--- a/plugins/mod_pubsub.lua
+++ b/plugins/mod_pubsub.lua
@@ -37,6 +37,24 @@ function pubsub_error_reply(stanza, error)
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