From e6ae29065d034dc23a0cc0ac4874956b931dd1c9 Mon Sep 17 00:00:00 2001
From: Tobias Markmann <tm@ayena.de>
Date: Tue, 28 Oct 2014 13:35:56 +0100
Subject: Only handle impromptu MUC invites once.

Added missing return-statement after handling the conversion from 1-to-1 to MUC.
This lead to an additional tab being opened.
In addition the indentation of the relevant block was wrong and is fixed now.

Test-Information:

Before there was a reproducible scenario: test@A starts to chat with test2@A.
toast@A is on test@A's roster, but not on test2@A's roster. test@A drops toast@A
on the running chat between test@A and test2@A. test@A and test2@A end up with
the chat converted into a MUC. toast@A automatically joins the MUC. test2@A
additionally has a new tab.
Now test2@A does not have the additional tab anymore. Only the MUC tab which
previously was a 1-to-1 tab.

Change-Id: I32045812952c840f0f9c6da3a9aecf5c63797b64

diff --git a/Swift/Controllers/Chat/ChatsManager.cpp b/Swift/Controllers/Chat/ChatsManager.cpp
index 3ff2a3d..979f87a 100644
--- a/Swift/Controllers/Chat/ChatsManager.cpp
+++ b/Swift/Controllers/Chat/ChatsManager.cpp
@@ -889,18 +889,19 @@ void ChatsManager::handleIncomingMessage(boost::shared_ptr<Message> message) {
 	MUCInvitationPayload::ref invite = message->getPayload<MUCInvitationPayload>();
 	if (invite && autoAcceptMUCInviteDecider_->isAutoAcceptedInvite(message->getFrom(), invite)) {
 		if (invite->getIsContinuation()) {
-				// check for existing chat controller for the from JID
-				ChatController* controller = getChatControllerIfExists(jid);
-				if (controller) {
-					ChatWindow* window = controller->detachChatWindow();
-					chatControllers_.erase(jid);
-					delete controller;
-					handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true, window);
-				}
-			} else {
-				handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true);
+			// check for existing chat controller for the from JID
+			ChatController* controller = getChatControllerIfExists(jid);
+			if (controller) {
+				ChatWindow* window = controller->detachChatWindow();
+				chatControllers_.erase(jid);
+				delete controller;
+				handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true, window);
 				return;
 			}
+		} else {
+			handleJoinMUCRequest(invite->getJID(), boost::optional<std::string>(), boost::optional<std::string>(), false, false, true);
+			return;
+		}
 	}
 
 	//if not a mucroom
-- 
cgit v0.10.2-6-g49f6