Comparison

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
comparison
equal deleted inserted replaced
3640:4bc88bb748d1 3641:3603aeb325de
33 local reply = st.error_reply(stanza, unpack(e, 1, 3)); 33 local reply = st.error_reply(stanza, unpack(e, 1, 3));
34 if e[4] then 34 if e[4] then
35 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up(); 35 reply:tag(e[4], { xmlns = xmlns_pubsub_errors }):up();
36 end 36 end
37 return reply; 37 return reply;
38 end
39
40 function handlers.get_items(origin, stanza, items)
41 local node = items.attr.node;
42 local item = items:get_child("item");
43 local id = item and item.attr.id;
44 local data = st.stanza("items", { node = node });
45 for _, entry in pairs(service:get(node, stanza.attr.from, id)) do
46 data:add_child(entry);
47 end
48 if data then
49 reply = st.reply(stanza)
50 :tag("pubsub", { xmlns = xmlns_pubsub })
51 :add_child(data);
52 else
53 reply = st.error_reply(stanza, "cancel", "item-not-found", "Item could not be found in this node");
54 end
55 return origin.send(reply);
38 end 56 end
39 57
40 function handlers.set_subscribe(origin, stanza, subscribe) 58 function handlers.set_subscribe(origin, stanza, subscribe)
41 local node, jid = subscribe.attr.node, subscribe.attr.jid; 59 local node, jid = subscribe.attr.node, subscribe.attr.jid;
42 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then 60 if jid_bare(jid) ~= jid_bare(stanza.attr.from) then