aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2013-01-24 00:58:03 +0100
committerKim Alvefur <zash@zash.se>2013-01-24 00:58:03 +0100
commitfb589d8634dd86e2f110801d71ae93925500d4d6 (patch)
tree78a916a081a9dce7b30bc01cd1554382d337f875 /plugins
parent0a3ffba7ba6c1784c3a41bdc73946510e4ad20a6 (diff)
downloadprosody-fb589d8634dd86e2f110801d71ae93925500d4d6.tar.gz
prosody-fb589d8634dd86e2f110801d71ae93925500d4d6.zip
mod_pubsub, util.pubsub: Implement the purge action
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_pubsub.lua25
1 files changed, 25 insertions, 0 deletions
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" };