From 2f6d7308c569b29822540bca143236ded2526c2d Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Thu, 6 Mar 2025 15:54:35 +0000 Subject: [PATCH] Make joining remote rooms more reliable When joining remote rooms we have to specify another homeserver (that is in the room) to help us join. The matrix documentation is a little unclear what to do in this scenario, so instead of giving up let's at least brute force it with the server in the alias or room id. This *does* work and allows my server to join rooms in NeoChat I otherwise couldn't. BUG: 487253 CCBUG: 491359 FIXED-IN: 24.12.3 (cherry picked from commit f1253e4ede7ba6455273556a14993f49835bd86e) Co-authored-by: Joshua Goins --- src/roommanager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/roommanager.cpp b/src/roommanager.cpp index 4f3833081..0ef3b6afe 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -323,7 +323,15 @@ void RoomManager::visitRoom(Room *r, const QString &eventId) void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers) { - auto job = account->joinRoom(roomAliasOrId, viaServers); + QStringList vias = viaServers; + + // If no one gives us a homeserver suggestion, try the server specified in the alias/id. + // Otherwise joining a remote room not on our homeserver will fail. + if (vias.empty()) { + vias.append(roomAliasOrId.mid(roomAliasOrId.lastIndexOf(':'_L1) + 1)); + } + + auto job = account->joinRoom(roomAliasOrId, vias); connect( job.get(), &Quotient::BaseJob::finished,