Diff

core/rostermanager.lua @ 5060:b0e36777f715

mod_presence, rostermanager: Bring outbound subscription cancellation in line with RFC6121.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 01 Aug 2012 01:36:16 +0500
parent 5024:d25e1b9332cc
child 5348:ca0d820e9318
line wrap: on
line diff
--- a/core/rostermanager.lua	Wed Aug 01 01:36:13 2012 +0500
+++ b/core/rostermanager.lua	Wed Aug 01 01:36:16 2012 +0500
@@ -278,23 +278,21 @@
 	local roster = load_roster(username, host);
 	local item = roster[jid];
 	local pending = is_contact_pending_in(username, host, jid);
-	local changed = nil;
-	if is_contact_pending_in(username, host, jid) then
+	if pending then
 		roster.pending[jid] = nil; -- TODO maybe delete roster.pending if empty?
-		changed = true;
 	end
+	local subscribed;
 	if item then
 		if item.subscription == "from" then
 			item.subscription = "none";
-			changed = true;
+			subscribed = true;
 		elseif item.subscription == "both" then
 			item.subscription = "to";
-			changed = true;
+			subscribed = true;
 		end
 	end
-	if changed then
-		return save_roster(username, host, roster);
-	end
+	local success = (pending or subscribed) and save_roster(username, host, roster);
+	return success, pending, subscribed;
 end
 
 function process_outbound_subscription_request(username, host, jid)