mod_pep: Remove PEP subscriptions on getting a presence unsubscribe.

Sun, 28 Nov 2010 15:02:56 +0500

author
Waqas Hussain <waqas20@gmail.com>
date
Sun, 28 Nov 2010 15:02:56 +0500
changeset 3668
29a340777d7b
parent 3667
5c39dce29eaf
child 3669
4b56cd1302d4

mod_pep: Remove PEP subscriptions on getting a presence unsubscribe.

plugins/mod_pep.lua file | annotate | diff | comparison | revisions
--- a/plugins/mod_pep.lua	Sun Nov 28 13:11:42 2010 +0500
+++ b/plugins/mod_pep.lua	Sun Nov 28 15:02:56 2010 +0500
@@ -145,6 +145,16 @@
 		end
 	elseif t == "unavailable" then
 		if recipients[user] then recipients[user][stanza.attr.from] = nil; end
+	elseif not self and t == "unsubscribe" then
+		local from = jid_bare(stanza.attr.from);
+		local subscriptions = recipients[user];
+		if subscriptions then
+			for subscriber in pairs(subscriptions) do
+				if jid_bare(subscriber) == from then
+					recipients[user][subscriber] = nil;
+				end
+			end
+		end
 	end
 end, 10);
 

mercurial