Prioritise joining rooms by alias if available and letting the homeserver do the right thing

This commit is contained in:
Stefan Ceriu
2024-06-12 15:55:12 +03:00
committed by Stefan Ceriu
parent a2faae20c2
commit b73e5e9e5d
4 changed files with 101 additions and 6 deletions
@@ -385,6 +385,20 @@ class ClientProxy: ClientProxyProtocol {
}
}
func joinRoomAlias(_ roomAlias: String) async -> Result<Void, ClientProxyError> {
do {
let room = try await client.joinRoomByIdOrAlias(roomIdOrAlias: roomAlias, serverNames: [])
// Wait for the room to appear in the room lists to avoid issues downstream
let _ = await waitForRoomSummary(with: .success(room.id()), name: nil, timeout: 30)
return .success(())
} catch {
MXLog.error("Failed joining roomAlias: \(roomAlias) with error: \(error)")
return .failure(.sdkError(error))
}
}
func uploadMedia(_ media: MediaInfo) async -> Result<String, ClientProxyError> {
guard let mimeType = media.mimeType else {
MXLog.error("Failed uploading media, invalid mime type: \(media)")