aboutsummaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2011-08-30 15:48:16 -0400
committerMatthew Wild <mwild1@gmail.com>2011-08-30 15:48:16 -0400
commit97f91932f71193f14fdbe44604c03965525db140 (patch)
treee94457a9e59d32c95cd0d6d34b7101e2a883ec83 /util
parenta1430fb462f9e063338c40464590c496d3cc2562 (diff)
downloadprosody-97f91932f71193f14fdbe44604c03965525db140.tar.gz
prosody-97f91932f71193f14fdbe44604c03965525db140.zip
util.pubsub: Add service:remove_all_subscriptions()
Diffstat (limited to 'util')
-rw-r--r--util/pubsub.lua26
1 files changed, 26 insertions, 0 deletions
diff --git a/util/pubsub.lua b/util/pubsub.lua
index 621cf1a6..df055c7a 100644
--- a/util/pubsub.lua
+++ b/util/pubsub.lua
@@ -171,6 +171,32 @@ function service:remove_subscription(node, actor, jid)
return true;
end
+function service:remove_all_subscriptions(actor, jid)
+ -- Access checking
+ local cap;
+ if actor == true or jid == actor or self:jids_equal(actor, jid) then
+ cap = "unsubscribe";
+ else
+ cap = "unsubscribe_other";
+ end
+ if not self:may(node, actor, cap) then
+ return false, "forbidden";
+ end
+ if not self:may(node, jid, "be_unsubscribed") then
+ return false, "forbidden";
+ end
+ --
+ local normal_jid = self.config.normalize_jid(jid);
+ local subs = self.subscriptions[normal_jid]
+ subs = subs and subs[jid];
+ if subs then
+ for node in pairs(subs) do
+ self:remove_subscription(node, true, jid);
+ end
+ end
+ return true;
+end
+
function service:get_subscription(node, actor, jid)
-- Access checking
local cap;