From c1663b9b935eeeef87fb242e09efc48a1b1b5dca Mon Sep 17 00:00:00 2001
From: Kevin Smith <git@kismith.co.uk>
Date: Tue, 18 Oct 2011 15:27:12 +0100
Subject: When changing affiliation, only send the new one.

Previously removing from admin and adding to members would send both none and member, causing people to be ejected from members-only rooms.

Resolves: #1016

diff --git a/Swift/Controllers/Chat/MUCController.cpp b/Swift/Controllers/Chat/MUCController.cpp
index 30e85ad..6d3f9f2 100644
--- a/Swift/Controllers/Chat/MUCController.cpp
+++ b/Swift/Controllers/Chat/MUCController.cpp
@@ -645,8 +645,16 @@ void MUCController::handleGetAffiliationsRequest() {
 typedef std::pair<MUCOccupant::Affiliation, JID> AffiliationChangePair;
 
 void MUCController::handleChangeAffiliationsRequest(const std::vector<std::pair<MUCOccupant::Affiliation, JID> >& changes) {
+	std::set<JID> addedJIDs;
 	foreach (const AffiliationChangePair& change, changes) {
-		muc_->changeAffiliation(change.second, change.first);
+		if (change.first != MUCOccupant::NoAffiliation) {
+			addedJIDs.insert(change.second);
+		}
+	}
+	foreach (const AffiliationChangePair& change, changes) {
+		if (change.first != MUCOccupant::NoAffiliation || addedJIDs.find(change.second) == addedJIDs.end()) {
+			muc_->changeAffiliation(change.second, change.first);
+		}
 	}
 }
 
-- 
cgit v0.10.2-6-g49f6