Software /
code /
prosody
Diff
plugins/mod_pubsub.lua @ 5305:391b72fede9f
mod_pubsub, util.pubsub: Implement the purge action
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 24 Jan 2013 00:58:03 +0100 |
parent | 5304:67a49d47ef39 |
child | 5308:fd3219d64414 |
line wrap: on
line diff
--- a/plugins/mod_pubsub.lua Wed Jan 23 22:41:18 2013 +0100 +++ b/plugins/mod_pubsub.lua Thu Jan 24 00:58:03 2013 +0100 @@ -178,6 +178,10 @@ 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 @@ 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 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" };