diff options
-rw-r--r-- | lib/room.cpp | 33 | ||||
-rw-r--r-- | tests/quotest.cpp | 8 |
2 files changed, 16 insertions, 25 deletions
diff --git a/lib/room.cpp b/lib/room.cpp index 9c932ed6..c42e618e 100644 --- a/lib/room.cpp +++ b/lib/room.cpp @@ -2492,31 +2492,20 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) , [this, oldStateEvent] (const RoomCanonicalAliasEvent& cae) { // clang-format on setObjectName(cae.alias().isEmpty() ? d->id : cae.alias()); - QString previousCanonicalAlias = - oldStateEvent - ? static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent) - ->alias() - : QString(); - - auto previousAltAliases = - oldStateEvent - ? static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent) - ->altAliases() - : QStringList(); - - if (!previousCanonicalAlias.isEmpty()) { - previousAltAliases.push_back(previousCanonicalAlias); + const auto* oldCae = + static_cast<const RoomCanonicalAliasEvent*>(oldStateEvent); + QStringList previousAltAliases {}; + if (oldCae) { + previousAltAliases = oldCae->altAliases(); + if (!oldCae->alias().isEmpty()) + previousAltAliases.push_back(oldCae->alias()); } - const auto previousAliases = std::move(previousAltAliases); - auto newAliases = cae.altAliases(); - - if (!cae.alias().isEmpty()) { + if (!cae.alias().isEmpty()) newAliases.push_front(cae.alias()); - } - connection()->updateRoomAliases(id(), previousAliases, newAliases); + connection()->updateRoomAliases(id(), previousAltAliases, newAliases); return AliasesChange; // clang-format off } @@ -2552,7 +2541,9 @@ Room::Changes Room::processStateEvent(const RoomEvent& e) if (u == localUser() && evt.isDirect()) connection()->addToDirectChats(this, user(evt.senderId())); break; - default: + case MembershipType::Knock: + case MembershipType::Ban: + case MembershipType::Leave: if (!d->membersLeft.contains(u)) d->membersLeft.append(u); } diff --git a/tests/quotest.cpp b/tests/quotest.cpp index be95ee7d..edf0e014 100644 --- a/tests/quotest.cpp +++ b/tests/quotest.cpp @@ -186,7 +186,7 @@ TestManager::TestManager(int& argc, char** argv) connect(c, &Connection::connected, this, &TestManager::setupAndRun); connect(c, &Connection::resolveError, this, - [this](const QString& error) { + [](const QString& error) { clog << "Failed to resolve the server: " << error.toStdString() << endl; QCoreApplication::exit(-2); @@ -268,7 +268,7 @@ void TestManager::onNewRoom(Room* r) << endl; connect(r, &Room::aboutToAddNewMessages, r, [r](RoomEventsRange timeline) { clog << timeline.size() << " new event(s) in room " - << r->canonicalAlias().toStdString() << endl; + << r->objectName().toStdString() << endl; }); } @@ -319,13 +319,13 @@ TEST_IMPL(loadMembers) // It's not exactly correct because an arbitrary server might not support // lazy loading; but in the absence of capabilities framework we assume // it does. - if (r->memberNames().size() >= r->joinedCount()) { + if (r->users().size() >= r->joinedCount()) { clog << "Lazy loading doesn't seem to be enabled" << endl; FAIL_TEST(); } r->setDisplayed(); connect(r, &Room::allMembersLoaded, this, [this, thisTest, r] { - FINISH_TEST(r->memberNames().size() >= r->joinedCount()); + FINISH_TEST(r->users().size() >= r->joinedCount()); }); return false; } |