diff options
author | Kim Alvefur <zash@zash.se> | 2013-02-03 15:52:27 +0100 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2013-02-03 15:52:27 +0100 |
commit | 4c01dc18780c4b0b93616093c86b2c9cff3d12f2 (patch) | |
tree | a1d3fc24abd3048cb23d45b860640a83baa8c261 /util | |
parent | 8c8ebcc4aeb65184408557a5d3f967dd2b0e7e51 (diff) | |
parent | 517296667e0fa74dd441892cf9750101ae31e814 (diff) | |
download | prosody-4c01dc18780c4b0b93616093c86b2c9cff3d12f2.tar.gz prosody-4c01dc18780c4b0b93616093c86b2c9cff3d12f2.zip |
Merge 0.9->trunk
Diffstat (limited to 'util')
-rw-r--r-- | util/pubsub.lua | 35 | ||||
-rw-r--r-- | util/xmppstream.lua | 2 |
2 files changed, 33 insertions, 4 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua index 8ff458e7..e7fc86b1 100644 --- a/util/pubsub.lua +++ b/util/pubsub.lua @@ -226,6 +226,18 @@ function service:create(node, actor) return ok, err; end +function service:delete(node, actor) + -- Access checking + if not self:may(node, actor, "delete") then + return false, "forbidden"; + end + -- + local node_obj = self.nodes[node]; + self.nodes[node] = nil; + self.config.broadcaster("delete", node, node_obj.subscribers); + return true; +end + function service:publish(node, actor, id, item) -- Access checking if not self:may(node, actor, "publish") then @@ -245,7 +257,7 @@ function service:publish(node, actor, id, item) end node_obj.data[id] = item; self.events.fire_event("item-published", { node = node, actor = actor, id = id, item = item }); - self.config.broadcaster(node, node_obj.subscribers, item); + self.config.broadcaster("items", node, node_obj.subscribers, item); return true; end @@ -261,7 +273,24 @@ function service:retract(node, actor, id, retract) end node_obj.data[id] = nil; if retract then - self.config.broadcaster(node, node_obj.subscribers, retract); + self.config.broadcaster("items", node, node_obj.subscribers, retract); + end + return true +end + +function service:purge(node, actor, notify) + -- Access checking + if not self:may(node, actor, "retract") then + return false, "forbidden"; + end + -- + local node_obj = self.nodes[node]; + if not node_obj then + return false, "item-not-found"; + end + node_obj.data = {}; -- Purge + if notify then + self.config.broadcaster("purge", node, node_obj.subscribers); end return true end @@ -321,7 +350,7 @@ function service:get_subscriptions(node, actor, jid) if node then -- Return only subscriptions to this node if subscribed_nodes[node] then ret[#ret+1] = { - node = subscribed_node; + node = subscribed_nodes[node]; jid = jid; subscription = node_obj.subscribers[jid]; }; diff --git a/util/xmppstream.lua b/util/xmppstream.lua index f1793b4f..4909678c 100644 --- a/util/xmppstream.lua +++ b/util/xmppstream.lua @@ -45,7 +45,7 @@ function new_sax_handlers(session, stream_callbacks) local cb_streamopened = stream_callbacks.streamopened; local cb_streamclosed = stream_callbacks.streamclosed; - local cb_error = stream_callbacks.error or function(session, e) error("XML stream error: "..tostring(e)); end; + local cb_error = stream_callbacks.error or function(session, e, stanza) error("XML stream error: "..tostring(e)..(stanza and ": "..tostring(stanza) or ""),2); end; local cb_handlestanza = stream_callbacks.handlestanza; local stream_ns = stream_callbacks.stream_ns or xmlns_streams; |