Merge pull request #2661 from vector-im/feature/bma/fix_join

Fix request too large Uri error when joining a room
This commit is contained in:
Benoit Marty 2021-01-13 09:29:04 +01:00 committed by GitHub
commit 1d449c84fe
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View file

@ -18,6 +18,7 @@ Bugfix 🐛:
- Tapping drawer having more than 1 room in notifications gives "malformed link" error (#2605)
- Sent image not displayed when opened immediately after sending (#409)
- Initial sync is not retried correctly when there is some network error. (#2632)
- Fix request too large Uri error when joining a room
Translations 🗣:
-

View file

@ -55,7 +55,11 @@ internal class DefaultJoinRoomTask @Inject constructor(
roomChangeMembershipStateDataSource.updateState(params.roomIdOrAlias, ChangeMembershipState.Joining)
val joinRoomResponse = try {
executeRequest<JoinRoomResponse>(globalErrorReceiver) {
apiCall = roomAPI.join(params.roomIdOrAlias, params.viaServers, mapOf("reason" to params.reason))
apiCall = roomAPI.join(
roomIdOrAlias = params.roomIdOrAlias,
viaServers = params.viaServers.take(3),
params = mapOf("reason" to params.reason)
)
}
} catch (failure: Throwable) {
roomChangeMembershipStateDataSource.updateState(params.roomIdOrAlias, ChangeMembershipState.FailedJoining(failure))

View file

@ -84,22 +84,34 @@ class RoomPreviewViewModel @AssistedInject constructor(@Assisted private val ini
when (peekResult) {
is PeekResult.Success -> {
setState {
// Do not override what we had from the permalink
val newHomeServers = if (homeServers.isEmpty()) {
peekResult.viaServers.take(3)
} else {
homeServers
}
copy(
roomId = peekResult.roomId,
avatarUrl = peekResult.avatarUrl,
roomAlias = peekResult.alias ?: initialState.roomAlias,
roomTopic = peekResult.topic,
homeServers = peekResult.viaServers,
homeServers = newHomeServers,
peekingState = Success(PeekingState.FOUND)
)
}
}
is PeekResult.PeekingNotAllowed -> {
setState {
// Do not override what we had from the permalink
val newHomeServers = if (homeServers.isEmpty()) {
peekResult.viaServers.take(3)
} else {
homeServers
}
copy(
roomId = peekResult.roomId,
roomAlias = peekResult.alias ?: initialState.roomAlias,
homeServers = peekResult.viaServers,
homeServers = newHomeServers,
peekingState = Success(PeekingState.NO_ACCESS)
)
}