aboutsummaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorWaqas Hussain <waqas20@gmail.com>2009-06-24 19:38:28 +0500
committerWaqas Hussain <waqas20@gmail.com>2009-06-24 19:38:28 +0500
commitdbc046d1e57f3367eb88d58c805f6c947085acc9 (patch)
treeefbf7e21afc1cab96da80e8ee834f997f4c2a167 /plugins
parent537fab82602e0be67cdf95af75d658f10afcba7b (diff)
downloadprosody-dbc046d1e57f3367eb88d58c805f6c947085acc9.tar.gz
prosody-dbc046d1e57f3367eb88d58c805f6c947085acc9.zip
mod_pep: Remove data when a user disables a node
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mod_pep.lua11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/mod_pep.lua b/plugins/mod_pep.lua
index d0c9ea24..b09d9e20 100644
--- a/plugins/mod_pep.lua
+++ b/plugins/mod_pep.lua
@@ -6,6 +6,7 @@ local hosts = hosts;
local user_exists = require "core.usermanager".user_exists;
local is_contact_subscribed = require "core.rostermanager".is_contact_subscribed;
local pairs, ipairs = pairs, ipairs;
+local next = next;
local load_roster = require "core.rostermanager".load_roster;
local data = {};
@@ -15,6 +16,7 @@ module:add_identity("pubsub", "pep");
module:add_feature("http://jabber.org/protocol/pubsub#publish");
local function publish(session, node, item)
+ local disable = #item.tags ~= 1 or #item.tags[1].tags == 0;
local stanza = st.message({from=session.full_jid, type='headline'})
:tag('event', {xmlns='http://jabber.org/protocol/pubsub#event'})
:tag('items', {node=node})
@@ -25,8 +27,13 @@ local function publish(session, node, item)
local bare = session.username..'@'..session.host;
-- store for the future
local user_data = data[bare];
- if not user_data then user_data = {}; data[bare] = user_data; end
- user_data[node] = stanza;
+ if disable then
+ if user_data then user_data[node] = nil; end
+ if not next(user_data) then data[bare] = nil; end
+ else
+ if not user_data then user_data = {}; data[bare] = user_data; end
+ user_data[node] = stanza;
+ end
-- broadcast to resources
stanza.attr.to = bare;