for _, entry in pairs(results) do
data:add_child(entry);
end
+ local reply;
if data then
reply = st.reply(stanza)
:tag("pubsub", { xmlns = xmlns_pubsub })
function handlers.set_subscribe(origin, stanza, subscribe)
local node, jid = subscribe.attr.node, subscribe.attr.jid;
- local ok, ret = service:add_subscription(node, stanza.attr.from, jid);
+ local options_tag, options = stanza.tags[1]:get_child("options"), nil;
+ if options_tag then
+ options = options_form:data(options_tag.tags[1]);
+ end
+ local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options);
local reply;
if ok then
reply = st.reply(stanza)
node = node,
jid = jid,
subscription = "subscribed"
- });
+ }):up();
+ if options_tag then
+ reply:add_child(options_tag);
+ end
else
reply = pubsub_error_reply(stanza, ret);
end
- return origin.send(reply);
+ origin.send(reply);
+ if ok then
+ -- Send all current items
+ local ok, items = service:get_items(node, stanza.attr.from);
+ if items then
+ local jids = { [jid] = options or true };
+ for id, item in pairs(items) do
+ service.config.broadcaster(node, jids, item);
+ end
+ end
+ end
end
function handlers.set_unsubscribe(origin, stanza, unsubscribe)
for jid in pairs(jids) do
module:log("debug", "Sending notification to %s", jid);
message.attr.to = jid;
- core_post_stanza(hosts[module.host], message);
+ module:send(message);
end
end
set_affiliation = false;
};
+ publisher = {
+ create = false;
+ publish = true;
+ retract = true;
+ get_nodes = true;
+
+ subscribe = true;
+ unsubscribe = true;
+ get_subscription = true;
+ get_subscriptions = true;
+ get_items = true;
+
+ subscribe_other = false;
+ unsubscribe_other = false;
+ get_subscription_other = false;
+ get_subscriptions_other = false;
+
+ be_subscribed = true;
+ be_unsubscribed = true;
+
+ set_affiliation = false;
+ };
owner = {
create = true;
publish = true;
get_affiliation = get_affiliation;
normalize_jid = jid_bare;
-}));
\ No newline at end of file
+}));