Software /
code /
prosody
Diff
util/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 | 5181:1e9508ae44cc |
child | 5312:fdcd2ac7c22d |
line wrap: on
line diff
--- a/util/pubsub.lua Wed Jan 23 22:41:18 2013 +0100 +++ b/util/pubsub.lua Thu Jan 24 00:58:03 2013 +0100 @@ -259,13 +259,21 @@ if (not node_obj) or (not node_obj.data[id]) then return false, "item-not-found"; end - node_obj.data[id] = nil; + if id then + node_obj.data[id] = nil; + else + node_obj.data = {}; -- Purge + end if retract then self.config.broadcaster(node, node_obj.subscribers, retract); end return true end +function service:purge(node, actor, purge) + return self:retract(node, actor, nil, purge); +end + function service:get_items(node, actor, id) -- Access checking if not self:may(node, actor, "get_items") then