Browse Source

Merge pull request #3749 from element-hq/renovate/org.matrix.rustcomponents-sdk-android-0.x

Update dependency org.matrix.rustcomponents:sdk-android to v0.2.58
pull/3702/merge
Benoit Marty 22 hours ago committed by GitHub
parent
commit
e329370e5e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      gradle/libs.versions.toml
  2. 33
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/preview/RoomPreviewMapper.kt
  3. 9
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt
  4. 22
      libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/factories/RoomPreviewInfo.kt
  5. 21
      libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeRustRoomPreview.kt
  6. 28
      libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/preview/RoomPreviewMapperTest.kt

2
gradle/libs.versions.toml

@ -169,7 +169,7 @@ jsoup = "org.jsoup:jsoup:1.18.1" @@ -169,7 +169,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
timber = "com.jakewharton.timber:timber:5.0.1"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.57"
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.58"
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }

33
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/preview/RoomPreviewMapper.kt

@ -11,23 +11,28 @@ import io.element.android.libraries.matrix.api.core.RoomAlias @@ -11,23 +11,28 @@ import io.element.android.libraries.matrix.api.core.RoomAlias
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.room.preview.RoomPreview
import io.element.android.libraries.matrix.impl.room.toRoomType
import org.matrix.rustcomponents.sdk.JoinRule
import org.matrix.rustcomponents.sdk.Membership
import org.matrix.rustcomponents.sdk.RoomPreview as RustRoomPreview
object RoomPreviewMapper {
fun map(roomPreview: RustRoomPreview): RoomPreview {
return RoomPreview(
roomId = RoomId(roomPreview.roomId),
canonicalAlias = roomPreview.canonicalAlias?.let(::RoomAlias),
name = roomPreview.name,
topic = roomPreview.topic,
avatarUrl = roomPreview.avatarUrl,
numberOfJoinedMembers = roomPreview.numJoinedMembers.toLong(),
roomType = roomPreview.roomType.toRoomType(),
isHistoryWorldReadable = roomPreview.isHistoryWorldReadable,
isJoined = roomPreview.isJoined,
isInvited = roomPreview.isInvited,
isPublic = roomPreview.isPublic,
canKnock = roomPreview.canKnock
)
return roomPreview.use {
val info = roomPreview.info()
RoomPreview(
roomId = RoomId(info.roomId),
canonicalAlias = info.canonicalAlias?.let(::RoomAlias),
name = info.name,
topic = info.topic,
avatarUrl = info.avatarUrl,
numberOfJoinedMembers = info.numJoinedMembers.toLong(),
roomType = info.roomType.toRoomType(),
isHistoryWorldReadable = info.isHistoryWorldReadable,
isJoined = info.membership == Membership.JOINED,
isInvited = info.membership == Membership.INVITED,
isPublic = info.joinRule == JoinRule.Public,
canKnock = info.joinRule == JoinRule.Knock
)
}
}
}

9
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/verification/RustSessionVerificationService.kt

@ -35,6 +35,7 @@ import org.matrix.rustcomponents.sdk.RecoveryState @@ -35,6 +35,7 @@ import org.matrix.rustcomponents.sdk.RecoveryState
import org.matrix.rustcomponents.sdk.RecoveryStateListener
import org.matrix.rustcomponents.sdk.SessionVerificationController
import org.matrix.rustcomponents.sdk.SessionVerificationControllerDelegate
import org.matrix.rustcomponents.sdk.SessionVerificationRequestDetails
import org.matrix.rustcomponents.sdk.VerificationState
import org.matrix.rustcomponents.sdk.VerificationStateListener
import org.matrix.rustcomponents.sdk.use
@ -150,7 +151,7 @@ class RustSessionVerificationService( @@ -150,7 +151,7 @@ class RustSessionVerificationService(
// It also sometimes unexpectedly fails to report the session as verified, so we have to handle that possibility and fail if needed
runCatching {
withTimeout(30.seconds) {
while (!verificationController.isVerified()) {
while (encryptionService.verificationState() != VerificationState.VERIFIED) {
delay(100)
}
}
@ -176,6 +177,10 @@ class RustSessionVerificationService( @@ -176,6 +177,10 @@ class RustSessionVerificationService(
_verificationFlowState.value = VerificationFlowState.StartedSasVerification
}
override fun didReceiveVerificationRequest(details: SessionVerificationRequestDetails) {
// TODO
}
// end-region
override suspend fun reset() {
@ -227,7 +232,7 @@ class RustSessionVerificationService( @@ -227,7 +232,7 @@ class RustSessionVerificationService(
Timber.d("Updating verification status: flow is pending or was finished some time ago")
runCatching {
initVerificationControllerIfNeeded()
_sessionVerifiedStatus.value = if (verificationController.isVerified()) {
_sessionVerifiedStatus.value = if (encryptionService.verificationState() == VerificationState.VERIFIED) {
SessionVerifiedStatus.Verified
} else {
SessionVerifiedStatus.NotVerified

22
libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/factories/RoomPreview.kt → libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/factories/RoomPreviewInfo.kt

@ -9,16 +9,16 @@ package io.element.android.libraries.matrix.impl.fixtures.factories @@ -9,16 +9,16 @@ package io.element.android.libraries.matrix.impl.fixtures.factories
import io.element.android.libraries.matrix.test.A_ROOM_ALIAS
import io.element.android.libraries.matrix.test.A_ROOM_ID
import org.matrix.rustcomponents.sdk.RoomPreview
import org.matrix.rustcomponents.sdk.JoinRule
import org.matrix.rustcomponents.sdk.Membership
import org.matrix.rustcomponents.sdk.RoomPreviewInfo
internal fun aRustRoomPreview(
internal fun aRustRoomPreviewInfo(
canonicalAlias: String? = A_ROOM_ALIAS.value,
isJoined: Boolean = true,
isInvited: Boolean = true,
isPublic: Boolean = true,
canKnock: Boolean = true,
): RoomPreview {
return RoomPreview(
membership: Membership? = Membership.JOINED,
joinRule: JoinRule = JoinRule.Public,
): RoomPreviewInfo {
return RoomPreviewInfo(
roomId = A_ROOM_ID.value,
canonicalAlias = canonicalAlias,
name = "name",
@ -27,9 +27,7 @@ internal fun aRustRoomPreview( @@ -27,9 +27,7 @@ internal fun aRustRoomPreview(
numJoinedMembers = 1u,
roomType = null,
isHistoryWorldReadable = true,
isJoined = isJoined,
isInvited = isInvited,
isPublic = isPublic,
canKnock = canKnock,
membership = membership,
joinRule = joinRule,
)
}

21
libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/fixtures/fakes/FakeRustRoomPreview.kt

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
/*
* Copyright 2024 New Vector Ltd.
*
* SPDX-License-Identifier: AGPL-3.0-only
* Please see LICENSE in the repository root for full details.
*/
package io.element.android.libraries.matrix.impl.fixtures.fakes
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomPreviewInfo
import org.matrix.rustcomponents.sdk.NoPointer
import org.matrix.rustcomponents.sdk.RoomPreview
import org.matrix.rustcomponents.sdk.RoomPreviewInfo
class FakeRustRoomPreview(
private val info: RoomPreviewInfo = aRustRoomPreviewInfo(),
) : RoomPreview(NoPointer) {
override fun info(): RoomPreviewInfo {
return info
}
}

28
libraries/matrix/impl/src/test/kotlin/io/element/android/libraries/matrix/impl/room/preview/RoomPreviewMapperTest.kt

@ -10,19 +10,23 @@ package io.element.android.libraries.matrix.impl.room.preview @@ -10,19 +10,23 @@ package io.element.android.libraries.matrix.impl.room.preview
import com.google.common.truth.Truth.assertThat
import io.element.android.libraries.matrix.api.room.RoomType
import io.element.android.libraries.matrix.api.room.preview.RoomPreview
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomPreview
import io.element.android.libraries.matrix.impl.fixtures.factories.aRustRoomPreviewInfo
import io.element.android.libraries.matrix.impl.fixtures.fakes.FakeRustRoomPreview
import io.element.android.libraries.matrix.test.A_ROOM_ALIAS
import io.element.android.libraries.matrix.test.A_ROOM_ID
import org.junit.Test
import org.matrix.rustcomponents.sdk.JoinRule
import org.matrix.rustcomponents.sdk.Membership
class RoomPreviewMapperTest {
@Test
fun `map should map values 1`() {
assertThat(
RoomPreviewMapper.map(
aRustRoomPreview(
isJoined = false,
isInvited = false,
FakeRustRoomPreview(
info = aRustRoomPreviewInfo(
membership = null,
)
)
)
).isEqualTo(
@ -38,7 +42,7 @@ class RoomPreviewMapperTest { @@ -38,7 +42,7 @@ class RoomPreviewMapperTest {
isJoined = false,
isInvited = false,
isPublic = true,
canKnock = true,
canKnock = false,
)
)
}
@ -47,10 +51,12 @@ class RoomPreviewMapperTest { @@ -47,10 +51,12 @@ class RoomPreviewMapperTest {
fun `map should map values 2`() {
assertThat(
RoomPreviewMapper.map(
aRustRoomPreview(
canonicalAlias = null,
isPublic = false,
canKnock = false,
FakeRustRoomPreview(
info = aRustRoomPreviewInfo(
canonicalAlias = null,
membership = Membership.JOINED,
joinRule = JoinRule.Knock,
)
)
)
).isEqualTo(
@ -64,9 +70,9 @@ class RoomPreviewMapperTest { @@ -64,9 +70,9 @@ class RoomPreviewMapperTest {
roomType = RoomType.Room,
isHistoryWorldReadable = true,
isJoined = true,
isInvited = true,
isInvited = false,
isPublic = false,
canKnock = false,
canKnock = true,
)
)
}

Loading…
Cancel
Save