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 1 day 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"
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" } appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0" molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
timber = "com.jakewharton.timber:timber:5.0.1" 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 = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", 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" } 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
import io.element.android.libraries.matrix.api.core.RoomId 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.api.room.preview.RoomPreview
import io.element.android.libraries.matrix.impl.room.toRoomType 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 import org.matrix.rustcomponents.sdk.RoomPreview as RustRoomPreview
object RoomPreviewMapper { object RoomPreviewMapper {
fun map(roomPreview: RustRoomPreview): RoomPreview { fun map(roomPreview: RustRoomPreview): RoomPreview {
return RoomPreview( return roomPreview.use {
roomId = RoomId(roomPreview.roomId), val info = roomPreview.info()
canonicalAlias = roomPreview.canonicalAlias?.let(::RoomAlias), RoomPreview(
name = roomPreview.name, roomId = RoomId(info.roomId),
topic = roomPreview.topic, canonicalAlias = info.canonicalAlias?.let(::RoomAlias),
avatarUrl = roomPreview.avatarUrl, name = info.name,
numberOfJoinedMembers = roomPreview.numJoinedMembers.toLong(), topic = info.topic,
roomType = roomPreview.roomType.toRoomType(), avatarUrl = info.avatarUrl,
isHistoryWorldReadable = roomPreview.isHistoryWorldReadable, numberOfJoinedMembers = info.numJoinedMembers.toLong(),
isJoined = roomPreview.isJoined, roomType = info.roomType.toRoomType(),
isInvited = roomPreview.isInvited, isHistoryWorldReadable = info.isHistoryWorldReadable,
isPublic = roomPreview.isPublic, isJoined = info.membership == Membership.JOINED,
canKnock = roomPreview.canKnock 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
import org.matrix.rustcomponents.sdk.RecoveryStateListener import org.matrix.rustcomponents.sdk.RecoveryStateListener
import org.matrix.rustcomponents.sdk.SessionVerificationController import org.matrix.rustcomponents.sdk.SessionVerificationController
import org.matrix.rustcomponents.sdk.SessionVerificationControllerDelegate import org.matrix.rustcomponents.sdk.SessionVerificationControllerDelegate
import org.matrix.rustcomponents.sdk.SessionVerificationRequestDetails
import org.matrix.rustcomponents.sdk.VerificationState import org.matrix.rustcomponents.sdk.VerificationState
import org.matrix.rustcomponents.sdk.VerificationStateListener import org.matrix.rustcomponents.sdk.VerificationStateListener
import org.matrix.rustcomponents.sdk.use import org.matrix.rustcomponents.sdk.use
@ -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 // It also sometimes unexpectedly fails to report the session as verified, so we have to handle that possibility and fail if needed
runCatching { runCatching {
withTimeout(30.seconds) { withTimeout(30.seconds) {
while (!verificationController.isVerified()) { while (encryptionService.verificationState() != VerificationState.VERIFIED) {
delay(100) delay(100)
} }
} }
@ -176,6 +177,10 @@ class RustSessionVerificationService(
_verificationFlowState.value = VerificationFlowState.StartedSasVerification _verificationFlowState.value = VerificationFlowState.StartedSasVerification
} }
override fun didReceiveVerificationRequest(details: SessionVerificationRequestDetails) {
// TODO
}
// end-region // end-region
override suspend fun reset() { override suspend fun reset() {
@ -227,7 +232,7 @@ class RustSessionVerificationService(
Timber.d("Updating verification status: flow is pending or was finished some time ago") Timber.d("Updating verification status: flow is pending or was finished some time ago")
runCatching { runCatching {
initVerificationControllerIfNeeded() initVerificationControllerIfNeeded()
_sessionVerifiedStatus.value = if (verificationController.isVerified()) { _sessionVerifiedStatus.value = if (encryptionService.verificationState() == VerificationState.VERIFIED) {
SessionVerifiedStatus.Verified SessionVerifiedStatus.Verified
} else { } else {
SessionVerifiedStatus.NotVerified 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
import io.element.android.libraries.matrix.test.A_ROOM_ALIAS import io.element.android.libraries.matrix.test.A_ROOM_ALIAS
import io.element.android.libraries.matrix.test.A_ROOM_ID 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, canonicalAlias: String? = A_ROOM_ALIAS.value,
isJoined: Boolean = true, membership: Membership? = Membership.JOINED,
isInvited: Boolean = true, joinRule: JoinRule = JoinRule.Public,
isPublic: Boolean = true, ): RoomPreviewInfo {
canKnock: Boolean = true, return RoomPreviewInfo(
): RoomPreview {
return RoomPreview(
roomId = A_ROOM_ID.value, roomId = A_ROOM_ID.value,
canonicalAlias = canonicalAlias, canonicalAlias = canonicalAlias,
name = "name", name = "name",
@ -27,9 +27,7 @@ internal fun aRustRoomPreview(
numJoinedMembers = 1u, numJoinedMembers = 1u,
roomType = null, roomType = null,
isHistoryWorldReadable = true, isHistoryWorldReadable = true,
isJoined = isJoined, membership = membership,
isInvited = isInvited, joinRule = joinRule,
isPublic = isPublic,
canKnock = canKnock,
) )
} }

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

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

Loading…
Cancel
Save