Comparison

plugins/mod_pubsub.lua @ 3941:526624f7852e

mod_pubsub: Implement get_subscriptions
author Matthew Wild <mwild1@gmail.com>
date Wed, 22 Dec 2010 03:49:52 +0000
parent 3940:d55e67e4191a
child 3944:74a422abec11
comparison
equal deleted inserted replaced
3940:d55e67e4191a 3941:526624f7852e
65 reply = pubsub_error_reply(stanza, "item-not-found"); 65 reply = pubsub_error_reply(stanza, "item-not-found");
66 end 66 end
67 return origin.send(reply); 67 return origin.send(reply);
68 end 68 end
69 69
70 function handlers.get_subscriptions(origin, stanza, subscriptions)
71 local node = subscriptions.attr.node;
72 local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from);
73 if not ok then
74 return origin.send(pubsub_error_reply(stanza, ret));
75 end
76 local reply = st.reply(stanza)
77 :tag("subscriptions", { xmlns = xmlns_pubsub });
78 for _, sub in ipairs(ret) do
79 reply:tag("subscription", { node = sub.node, jid = sub.jid, subscription = 'subscribed' }):up();
80 end
81 return origin.send(reply);
82 end
83
70 function handlers.set_create(origin, stanza, create) 84 function handlers.set_create(origin, stanza, create)
71 local node = create.attr.node; 85 local node = create.attr.node;
72 local ok, ret, reply; 86 local ok, ret, reply;
73 if node then 87 if node then
74 ok, ret = service:create(node, stanza.attr.from); 88 ok, ret = service:create(node, stanza.attr.from);