From f1253e4ede7ba6455273556a14993f49835bd86e Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Wed, 5 Mar 2025 20:27:05 -0500 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 --- src/roommanager.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/roommanager.cpp b/src/roommanager.cpp index fd3618e80..adb48d882 100644 --- a/src/roommanager.cpp +++ b/src/roommanager.cpp @@ -324,7 +324,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,