mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 11:59:12 +03:00
Merge pull request #2779 from vector-im/feature/bca/fix_join_by_alias_deferation
Join room other federation via alias error
This commit is contained in:
commit
ad187f99bf
2 changed files with 21 additions and 14 deletions
|
@ -8,7 +8,7 @@ Improvements 🙌:
|
|||
-
|
||||
|
||||
Bugfix 🐛:
|
||||
-
|
||||
- Join room by alias other federation error (#2778)
|
||||
|
||||
Translations 🗣:
|
||||
-
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
package org.matrix.android.sdk.internal.session.room.peeking
|
||||
|
||||
import org.matrix.android.sdk.api.MatrixPatterns
|
||||
import org.matrix.android.sdk.api.extensions.tryOrNull
|
||||
import org.matrix.android.sdk.api.session.events.model.EventType
|
||||
import org.matrix.android.sdk.api.session.events.model.toModel
|
||||
import org.matrix.android.sdk.api.session.room.model.RoomAvatarContent
|
||||
|
@ -65,23 +66,29 @@ internal class DefaultPeekRoomTask @Inject constructor(
|
|||
}
|
||||
|
||||
// Is it a public room?
|
||||
val publicRepoResult = when (getRoomDirectoryVisibilityTask.execute(GetRoomDirectoryVisibilityTask.Params(roomId))) {
|
||||
RoomDirectoryVisibility.PRIVATE -> {
|
||||
// We cannot resolve this room :/
|
||||
null
|
||||
}
|
||||
RoomDirectoryVisibility.PUBLIC -> {
|
||||
val visibilityRes = tryOrNull("## PEEK: failed to get visibility") {
|
||||
getRoomDirectoryVisibilityTask.execute(GetRoomDirectoryVisibilityTask.Params(roomId))
|
||||
}
|
||||
val publicRepoResult = when (visibilityRes) {
|
||||
RoomDirectoryVisibility.PUBLIC -> {
|
||||
// Try to find it in directory
|
||||
val filter = if (isAlias) PublicRoomsFilter(searchTerm = params.roomIdOrAlias.substring(1))
|
||||
else null
|
||||
|
||||
getPublicRoomTask.execute(GetPublicRoomTask.Params(
|
||||
server = serverList.firstOrNull(),
|
||||
publicRoomsParams = PublicRoomsParams(
|
||||
filter = filter,
|
||||
limit = 20.takeIf { filter != null } ?: 100
|
||||
)
|
||||
)).chunk?.firstOrNull { it.roomId == roomId }
|
||||
tryOrNull("## PEEK: failed to GetPublicRoomTask") {
|
||||
getPublicRoomTask.execute(GetPublicRoomTask.Params(
|
||||
server = serverList.firstOrNull(),
|
||||
publicRoomsParams = PublicRoomsParams(
|
||||
filter = filter,
|
||||
limit = 20.takeIf { filter != null } ?: 100
|
||||
)
|
||||
))
|
||||
}?.chunk?.firstOrNull { it.roomId == roomId }
|
||||
}
|
||||
else -> {
|
||||
// RoomDirectoryVisibility.PRIVATE or null
|
||||
// We cannot resolve this room :/
|
||||
null
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue