Move Conversatino deletion into User class
This commit is contained in:
parent
d0699848cf
commit
672f91a630
3 changed files with 19 additions and 9 deletions
|
@ -1181,15 +1181,6 @@ void NetworkPluginServer::handleRoomLeft(User *user, const std::string &r) {
|
|||
return;
|
||||
}
|
||||
send(c->connection, message);
|
||||
|
||||
NetworkConversation *conv = (NetworkConversation *) user->getConversationManager()->getConversation(r);
|
||||
if (!conv) {
|
||||
return;
|
||||
}
|
||||
|
||||
user->getConversationManager()->removeConversation(conv);
|
||||
|
||||
delete conv;
|
||||
}
|
||||
|
||||
void NetworkPluginServer::handleUserDestroyed(User *user) {
|
||||
|
|
|
@ -26,6 +26,7 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
|
|||
CPPUNIT_TEST(handlePresence);
|
||||
CPPUNIT_TEST(handlePresenceJoinRoom);
|
||||
CPPUNIT_TEST(handlePresenceLeaveRoom);
|
||||
CPPUNIT_TEST(leaveJoinedRoom);
|
||||
CPPUNIT_TEST(handleDisconnected);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
||||
|
@ -191,6 +192,18 @@ class UserTest : public CPPUNIT_NS :: TestFixture, public BasicTest {
|
|||
CPPUNIT_ASSERT_EQUAL(std::string(""), roomPassword);
|
||||
}
|
||||
|
||||
void leaveJoinedRoom() {
|
||||
User *user = userManager->getUser("user@localhost");
|
||||
handlePresenceJoinRoom();
|
||||
|
||||
CPPUNIT_ASSERT(user->getConversationManager()->getConversation("#room"));
|
||||
|
||||
received.clear();
|
||||
handlePresenceLeaveRoom();
|
||||
|
||||
CPPUNIT_ASSERT(!user->getConversationManager()->getConversation("#room"));
|
||||
}
|
||||
|
||||
void handleDisconnected() {
|
||||
User *user = userManager->getUser("user@localhost");
|
||||
user->handleDisconnected("Connection error", Swift::SpectrumErrorPayload::CONNECTION_ERROR_AUTHENTICATION_FAILED);
|
||||
|
|
|
@ -217,6 +217,12 @@ void User::handlePresence(Swift::Presence::ref presence) {
|
|||
std::string room = Buddy::JIDToLegacyName(presence->getTo());
|
||||
LOG4CXX_INFO(logger, m_jid.toString() << ": Going to left room " << room);
|
||||
onRoomLeft(room);
|
||||
|
||||
Conversation *conv = m_conversationManager->getConversation(room);
|
||||
if (conv) {
|
||||
m_conversationManager->removeConversation(conv);
|
||||
delete conv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// force connection to legacy network to let backend to handle auto-join on connect.
|
||||
|
|
Loading…
Add table
Reference in a new issue