From 0a3ffba7ba6c1784c3a41bdc73946510e4ad20a6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Wed, 23 Jan 2013 22:41:18 +0100 Subject: mod_pubsub: Advertise autocreate_on_publish correctly. --- plugins/mod_pubsub.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 40b119cc..f0aa4e4f 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -210,9 +210,9 @@ module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq local disco_info; local feature_map = { - create = { "create-nodes", autocreate_on_publish and "instant-nodes", "item-ids" }; + create = { "create-nodes", "instant-nodes", "item-ids" }; retract = { "delete-items", "retract-items" }; - publish = { "publish" }; + publish = { "publish", autocreate_on_publish and "auto-create" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; get_subscriptions = { "retrieve-subscriptions" }; -- cgit v1.2.3 From fb589d8634dd86e2f110801d71ae93925500d4d6 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 00:58:03 +0100 Subject: mod_pubsub, util.pubsub: Implement the purge action --- plugins/mod_pubsub.lua | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index f0aa4e4f..687e38f1 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -178,6 +178,10 @@ function handlers.set_retract(origin, stanza, retract) notify = (notify == "1") or (notify == "true"); local item = retract:get_child("item"); local id = item and item.attr.id + if not (node and id) then + origin.send(st.error_reply(stanza, "modify", "bad-request")); + return true; + end local reply, notifier; if notify then notifier = st.stanza("retract", { id = id }); @@ -191,6 +195,26 @@ function handlers.set_retract(origin, stanza, retract) return origin.send(reply); end +function handlers.set_purge(origin, stanza, purge) + local node, notify = purge.attr.node, purge.attr.notify; + notify = (notify == "1") or (notify == "true"); + local reply, notifier; + if not node then + origin.send(st.error_reply(stanza, "modify", "bad-request")); + return true; + end + if notify then + notifier = st.stanza("purge"); + end + local ok, ret = service:purge(node, stanza.attr.from, notifier); + if ok then + reply = st.reply(stanza); + else + reply = pubsub_error_reply(stanza, ret); + end + return origin.send(reply); +end + function simple_broadcast(node, jids, item) item = st.clone(item); item.attr.xmlns = nil; -- Clear the pubsub namespace @@ -212,6 +236,7 @@ local disco_info; local feature_map = { create = { "create-nodes", "instant-nodes", "item-ids" }; retract = { "delete-items", "retract-items" }; + purge = { "purge-nodes" }; publish = { "publish", autocreate_on_publish and "auto-create" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; -- cgit v1.2.3 From db49dcc90c3df03e0c0c13a11429d26aec13c3f7 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 24 Jan 2013 16:36:48 +0100 Subject: mod_pubsub: Ignore subscription options for now, fixes traceback due to missing form --- plugins/mod_pubsub.lua | 3 +++ 1 file changed, 3 insertions(+) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 687e38f1..c840c7c2 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -111,10 +111,13 @@ end function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.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 options_tag, options; -- FIXME local ok, ret = service:add_subscription(node, stanza.attr.from, jid, options); local reply; if ok then -- cgit v1.2.3 From 75ef4319b9df8318842565cd34d3e9c8927b7f77 Mon Sep 17 00:00:00 2001 From: Florian Zeitz Date: Fri, 25 Jan 2013 01:32:14 +0100 Subject: mod_pubsub, util.pubsub: Don't send purge notifications in an element --- plugins/mod_pubsub.lua | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index c840c7c2..56fabaec 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -6,6 +6,7 @@ local uuid_generate = require "util.uuid".generate; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; local xmlns_pubsub_event = "http://jabber.org/protocol/pubsub#event"; +local xmlns_pubsub_owner = "http://jabber.org/protocol/pubsub#owner"; local autocreate_on_publish = module:get_option_boolean("autocreate_on_publish", false); local autocreate_on_subscribe = module:get_option_boolean("autocreate_on_subscribe", false); @@ -201,15 +202,12 @@ end function handlers.set_purge(origin, stanza, purge) local node, notify = purge.attr.node, purge.attr.notify; notify = (notify == "1") or (notify == "true"); - local reply, notifier; + local reply; if not node then origin.send(st.error_reply(stanza, "modify", "bad-request")); return true; end - if notify then - notifier = st.stanza("purge"); - end - local ok, ret = service:purge(node, stanza.attr.from, notifier); + local ok, ret = service:purge(node, stanza.attr.from, notify); if ok then reply = st.reply(stanza); else @@ -218,12 +216,14 @@ function handlers.set_purge(origin, stanza, purge) return origin.send(reply); end -function simple_broadcast(node, jids, item) - item = st.clone(item); - item.attr.xmlns = nil; -- Clear the pubsub namespace +function simple_broadcast(kind, node, jids, item) + if item then + item = st.clone(item); + item.attr.xmlns = nil; -- Clear the pubsub namespace + end local message = st.message({ from = module.host, type = "headline" }) :tag("event", { xmlns = xmlns_pubsub_event }) - :tag("items", { node = node }) + :tag(kind, { node = node }) :add_child(item); for jid in pairs(jids) do module:log("debug", "Sending notification to %s", jid); @@ -232,7 +232,8 @@ function simple_broadcast(node, jids, item) end end -module:hook("iq/host/http://jabber.org/protocol/pubsub:pubsub", handle_pubsub_iq); +module:hook("iq/host/"..xmlns_pubsub..":pubsub", handle_pubsub_iq); +module:hook("iq/host/"..xmlns_pubsub_owner..":pubsub", handle_pubsub_iq); local disco_info; -- cgit v1.2.3 From 082578c353742ca2ff6ccad9263483170914931e Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 26 Jan 2013 03:49:45 +0500 Subject: mod_pubsub: Fix nil access error. --- plugins/mod_pubsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 56fabaec..d39ba0fa 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -318,7 +318,7 @@ module:hook("iq-get/host/http://jabber.org/protocol/disco#items:query", function end local ok, ret = service:get_nodes(event.stanza.attr.from); if not ok then - event.origin.send(pubsub_error_reply(stanza, ret)); + event.origin.send(pubsub_error_reply(event.stanza, ret)); else local reply = st.reply(event.stanza) :tag("query", { xmlns = "http://jabber.org/protocol/disco#items" }); -- cgit v1.2.3 From 04f86293bd9156cc3dc1e9a2e96102682815cf92 Mon Sep 17 00:00:00 2001 From: Waqas Hussain Date: Sat, 26 Jan 2013 03:50:13 +0500 Subject: mod_pubsub: require usermanager. --- plugins/mod_pubsub.lua | 1 + 1 file changed, 1 insertion(+) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index d39ba0fa..56496584 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -2,6 +2,7 @@ local pubsub = require "util.pubsub"; local st = require "util.stanza"; local jid_bare = require "util.jid".bare; local uuid_generate = require "util.uuid".generate; +local usermanager = require "core.usermanager"; local xmlns_pubsub = "http://jabber.org/protocol/pubsub"; local xmlns_pubsub_errors = "http://jabber.org/protocol/pubsub#errors"; -- cgit v1.2.3 From c4104be6665ba29e87a49d71fc3850af23c34cc1 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Mon, 28 Jan 2013 01:06:05 +0100 Subject: mod_pubsub: Broadcast items correctly on new subscriptions --- plugins/mod_pubsub.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 56496584..8b6aea6c 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -143,7 +143,7 @@ function handlers.set_subscribe(origin, stanza, subscribe) if items then local jids = { [jid] = options or true }; for id, item in pairs(items) do - service.config.broadcaster(node, jids, item); + service.config.broadcaster("items", node, jids, item); end end end -- cgit v1.2.3 From f721b83d7b2f17ca953da5820a855f9712f1af4d Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 31 Jan 2013 15:33:41 +0100 Subject: mod_pubsub: More strict checks for node and ids --- plugins/mod_pubsub.lua | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 8b6aea6c..96a9eaae 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -32,6 +32,8 @@ end local pubsub_errors = { ["conflict"] = { "cancel", "conflict" }; ["invalid-jid"] = { "modify", "bad-request", nil, "invalid-jid" }; + ["jid-required"] = { "modify", "bad-request", nil, "jid-required" }; + ["nodeid-required"] = { "modify", "bad-request", nil, "nodeid-required" }; ["item-not-found"] = { "cancel", "item-not-found" }; ["not-subscribed"] = { "modify", "unexpected-request", nil, "not-subscribed" }; ["forbidden"] = { "cancel", "forbidden" }; @@ -50,6 +52,9 @@ function handlers.get_items(origin, stanza, items) local item = items:get_child("item"); local id = item and item.attr.id; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local ok, results = service:get_items(node, stanza.attr.from, id); if not ok then return origin.send(pubsub_error_reply(stanza, results)); @@ -72,6 +77,9 @@ end function handlers.get_subscriptions(origin, stanza, subscriptions) local node = subscriptions.attr.node; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local ok, ret = service:get_subscriptions(node, stanza.attr.from, stanza.attr.from); if not ok then return origin.send(pubsub_error_reply(stanza, ret)); @@ -113,6 +121,9 @@ end function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; + if not (node and jid) then + return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); + end --[[ local options_tag, options = stanza.tags[1]:get_child("options"), nil; if options_tag then @@ -151,6 +162,9 @@ end function handlers.set_unsubscribe(origin, stanza, unsubscribe) local node, jid = unsubscribe.attr.node, unsubscribe.attr.jid; + if not (node and jid) then + return origin.send(pubsub_error_reply(stanza, jid and "nodeid-required" or "invalid-jid")); + end local ok, ret = service:remove_subscription(node, stanza.attr.from, jid); local reply; if ok then @@ -163,6 +177,9 @@ end function handlers.set_publish(origin, stanza, publish) local node = publish.attr.node; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end local item = publish:get_child("item"); local id = (item and item.attr.id) or uuid_generate(); local ok, ret = service:publish(node, stanza.attr.from, id, item); @@ -184,8 +201,7 @@ function handlers.set_retract(origin, stanza, retract) local item = retract:get_child("item"); local id = item and item.attr.id if not (node and id) then - origin.send(st.error_reply(stanza, "modify", "bad-request")); - return true; + return origin.send(pubsub_error_reply(stanza, node and "item-not-found" or "nodeid-required")); end local reply, notifier; if notify then @@ -205,8 +221,7 @@ function handlers.set_purge(origin, stanza, purge) notify = (notify == "1") or (notify == "true"); local reply; if not node then - origin.send(st.error_reply(stanza, "modify", "bad-request")); - return true; + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); end local ok, ret = service:purge(node, stanza.attr.from, notify); if ok then -- cgit v1.2.3 From 517296667e0fa74dd441892cf9750101ae31e814 Mon Sep 17 00:00:00 2001 From: Kim Alvefur Date: Thu, 31 Jan 2013 18:41:01 +0100 Subject: mod_pubsub, util.pubsub: Add delete action --- plugins/mod_pubsub.lua | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'plugins/mod_pubsub.lua') diff --git a/plugins/mod_pubsub.lua b/plugins/mod_pubsub.lua index 96a9eaae..fe6c0b0a 100644 --- a/plugins/mod_pubsub.lua +++ b/plugins/mod_pubsub.lua @@ -119,6 +119,22 @@ function handlers.set_create(origin, stanza, create) return origin.send(reply); end +function handlers.set_delete(origin, stanza, delete) + local node = delete.attr.node; + + local reply, notifier; + if not node then + return origin.send(pubsub_error_reply(stanza, "nodeid-required")); + end + local ok, ret = service:delete(node, stanza.attr.from); + if ok then + reply = st.reply(stanza); + else + reply = pubsub_error_reply(stanza, ret); + end + return origin.send(reply); +end + function handlers.set_subscribe(origin, stanza, subscribe) local node, jid = subscribe.attr.node, subscribe.attr.jid; if not (node and jid) then @@ -258,6 +274,7 @@ local feature_map = { retract = { "delete-items", "retract-items" }; purge = { "purge-nodes" }; publish = { "publish", autocreate_on_publish and "auto-create" }; + delete = { "delete-nodes" }; get_items = { "retrieve-items" }; add_subscription = { "subscribe" }; get_subscriptions = { "retrieve-subscriptions" }; @@ -418,6 +435,7 @@ set_service(pubsub.new({ create = true; publish = true; retract = true; + delete = true; get_nodes = true; subscribe = true; -- cgit v1.2.3