local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false);
local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false);
+local pubsub_disco_name = module:get_option("name");
+if type(pubsub_disco_name) ~= "string" then pubsub_disco_name = "Prosody PubSub Service"; end
local service;
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
local function build_disco_info(service)
local disco_info = st.stanza("query", { xmlns = "http://jabber.org/protocol/disco#info" })
- :tag("identity", { category = "pubsub", type = "service" }):up()
+ :tag("identity", { category = "pubsub", type = "service", name = pubsub_disco_name }):up()
:tag("feature", { var = "http://jabber.org/protocol/pubsub" }):up();
add_disco_features_from_service(disco_info, service);
return disco_info;
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;