Skip to content

Commit 9fb68fc

Browse files
BillCarsonFrjmartinespElementBotbmarty
authored
Bump rust-sdk version to rust-sdk 0.2.57 (#3735)
* Bump rust-sdk version to rust-sdk 0.2.57 * rust sdk update: Support persisted WedgeQueueError * Trust & Decoration | Support new expected UTD causes * Room Subscribtion settings not needed anymore (see matrix-org/matrix-rust-sdk#4159) * File/Attachement upload: update to support `storeInCache` * feat(knock): update API to use reason and serverNames * Add another `Konsist` exception * Update screenshots --------- Co-authored-by: Jorge Martín <[email protected]> Co-authored-by: ElementBot <[email protected]> Co-authored-by: Benoit Marty <[email protected]>
1 parent f44c8dd commit 9fb68fc

File tree

23 files changed

+223
-58
lines changed

23 files changed

+223
-58
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* Copyright 2024 New Vector Ltd.
3+
*
4+
* SPDX-License-Identifier: AGPL-3.0-only
5+
* Please see LICENSE in the repository root for full details.
6+
*/
7+
8+
package io.element.android.features.messages.impl.timeline.components
9+
10+
import androidx.compose.foundation.layout.Column
11+
import androidx.compose.runtime.Composable
12+
import io.element.android.features.messages.impl.timeline.aTimelineItemEvent
13+
import io.element.android.features.messages.impl.timeline.aTimelineItemReactions
14+
import io.element.android.features.messages.impl.timeline.model.TimelineItemGroupPosition
15+
import io.element.android.features.messages.impl.timeline.model.event.TimelineItemEncryptedContent
16+
import io.element.android.libraries.designsystem.preview.ElementPreview
17+
import io.element.android.libraries.designsystem.preview.PreviewsDayNight
18+
import io.element.android.libraries.matrix.api.timeline.item.event.UnableToDecryptContent
19+
import io.element.android.libraries.matrix.api.timeline.item.event.UtdCause
20+
21+
@PreviewsDayNight
22+
@Composable
23+
internal fun TimelineItemEventRowUtdPreview() = ElementPreview {
24+
Column {
25+
ATimelineItemEventRow(
26+
event = aTimelineItemEvent(
27+
senderDisplayName = "Alice",
28+
isMine = false,
29+
content = TimelineItemEncryptedContent(
30+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
31+
sessionId = "sessionId",
32+
utdCause = UtdCause.UnsignedDevice,
33+
)
34+
),
35+
timelineItemReactions = aTimelineItemReactions(count = 0),
36+
groupPosition = TimelineItemGroupPosition.First,
37+
),
38+
)
39+
ATimelineItemEventRow(
40+
event = aTimelineItemEvent(
41+
senderDisplayName = "Bob",
42+
isMine = false,
43+
content = TimelineItemEncryptedContent(
44+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
45+
sessionId = "sessionId",
46+
utdCause = UtdCause.VerificationViolation,
47+
)
48+
),
49+
groupPosition = TimelineItemGroupPosition.First,
50+
timelineItemReactions = aTimelineItemReactions(count = 0)
51+
),
52+
)
53+
54+
ATimelineItemEventRow(
55+
event = aTimelineItemEvent(
56+
senderDisplayName = "Bob",
57+
isMine = false,
58+
content = TimelineItemEncryptedContent(
59+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
60+
sessionId = "sessionId",
61+
utdCause = UtdCause.SentBeforeWeJoined,
62+
)
63+
),
64+
groupPosition = TimelineItemGroupPosition.Last,
65+
timelineItemReactions = aTimelineItemReactions(count = 0)
66+
),
67+
)
68+
}
69+
}

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/components/event/TimelineItemEncryptedView.kt

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,28 @@ fun TimelineItemEncryptedView(
2727
onContentLayoutChange: (ContentAvoidingLayoutData) -> Unit,
2828
modifier: Modifier = Modifier
2929
) {
30-
val isMembershipUtd = (content.data as? UnableToDecryptContent.Data.MegolmV1AesSha2)?.utdCause == UtdCause.Membership
31-
val (textId, iconId) = if (isMembershipUtd) {
32-
CommonStrings.common_unable_to_decrypt_no_access to CompoundDrawables.ic_compound_block
33-
} else {
34-
CommonStrings.common_waiting_for_decryption_key to CompoundDrawables.ic_compound_time
30+
val (textId, iconId) = when (content.data) {
31+
is UnableToDecryptContent.Data.MegolmV1AesSha2 -> {
32+
when (content.data.utdCause) {
33+
UtdCause.SentBeforeWeJoined -> {
34+
CommonStrings.common_unable_to_decrypt_no_access to CompoundDrawables.ic_compound_block
35+
}
36+
UtdCause.VerificationViolation -> {
37+
CommonStrings.common_unable_to_decrypt_verification_violation to CompoundDrawables.ic_compound_block
38+
}
39+
UtdCause.UnsignedDevice,
40+
UtdCause.UnknownDevice -> {
41+
CommonStrings.common_unable_to_decrypt_insecure_device to CompoundDrawables.ic_compound_block
42+
}
43+
else -> {
44+
CommonStrings.common_waiting_for_decryption_key to CompoundDrawables.ic_compound_time
45+
}
46+
}
47+
}
48+
else -> {
49+
// Should not happen, we only supports megolm in rooms
50+
CommonStrings.common_waiting_for_decryption_key to CompoundDrawables.ic_compound_time
51+
}
3552
}
3653
TimelineItemInformativeView(
3754
text = stringResource(id = textId),

features/messages/impl/src/main/kotlin/io/element/android/features/messages/impl/timeline/model/event/TimelineItemEncryptedContentProvider.kt

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,19 @@ open class TimelineItemEncryptedContentProvider : PreviewParameterProvider<Timel
1818
aTimelineItemEncryptedContent(
1919
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
2020
sessionId = "sessionId",
21-
utdCause = UtdCause.Membership,
21+
utdCause = UtdCause.SentBeforeWeJoined,
22+
)
23+
),
24+
aTimelineItemEncryptedContent(
25+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
26+
sessionId = "sessionId",
27+
utdCause = UtdCause.VerificationViolation,
28+
)
29+
),
30+
aTimelineItemEncryptedContent(
31+
data = UnableToDecryptContent.Data.MegolmV1AesSha2(
32+
sessionId = "sessionId",
33+
utdCause = UtdCause.UnsignedDevice,
2234
)
2335
),
2436
aTimelineItemEncryptedContent(

gradle/libs.versions.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ jsoup = "org.jsoup:jsoup:1.18.1"
169169
appyx_core = { module = "com.bumble.appyx:core", version.ref = "appyx" }
170170
molecule-runtime = "app.cash.molecule:molecule-runtime:2.0.0"
171171
timber = "com.jakewharton.timber:timber:5.0.1"
172-
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.56"
172+
matrix_sdk = "org.matrix.rustcomponents:sdk-android:0.2.57"
173173
matrix_richtexteditor = { module = "io.element.android:wysiwyg", version.ref = "wysiwyg" }
174174
matrix_richtexteditor_compose = { module = "io.element.android:wysiwyg-compose", version.ref = "wysiwyg" }
175175
sqldelight-driver-android = { module = "app.cash.sqldelight:android-driver", version.ref = "sqldelight" }
@@ -193,7 +193,7 @@ zxing_cpp = "io.github.zxing-cpp:android:2.2.0"
193193
posthog = "com.posthog:posthog-android:3.8.2"
194194
sentry = "io.sentry:sentry-android:7.15.0"
195195
# main branch can be tested replacing the version with main-SNAPSHOT
196-
matrix_analytics_events = "com.github.matrix-org:matrix-analytics-events:0.25.0"
196+
matrix_analytics_events = "com.github.matrix-org:matrix-analytics-events:0.27.0"
197197

198198
# Emojibase
199199
matrix_emojibase_bindings = "io.element.android:emojibase-bindings:1.3.3"

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/LocalEventSendState.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ sealed interface LocalEventSendState {
1717
data object Sending : LocalEventSendState
1818
sealed interface Failed : LocalEventSendState {
1919
data class Unknown(val error: String) : Failed
20-
data object CrossSigningNotSetup : Failed
2120
data object SendingFromUnverifiedDevice : Failed
2221

2322
sealed interface VerifiedUser : Failed

libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/timeline/item/event/UtdCause.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,8 @@ package io.element.android.libraries.matrix.api.timeline.item.event
99

1010
enum class UtdCause {
1111
Unknown,
12-
Membership,
12+
SentBeforeWeJoined,
13+
VerificationViolation,
14+
UnsignedDevice,
15+
UnknownDevice
1316
}

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/RustMatrixClient.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ class RustMatrixClient(
398398
sessionDispatcher
399399
) {
400400
runCatching {
401-
client.knock(roomIdOrAlias.identifier).destroy()
401+
client.knock(roomIdOrAlias.identifier, message, serverNames).destroy()
402402
try {
403403
awaitRoom(roomIdOrAlias, 10.seconds, CurrentUserMembership.KNOCKED)
404404
} catch (e: Exception) {

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/analytics/UtdTracker.kt

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ class UtdTracker(
2121
Timber.d("onUtd for event ${info.eventId}, timeToDecryptMs: ${info.timeToDecryptMs}")
2222
val name = when (info.cause) {
2323
UtdCause.UNKNOWN -> Error.Name.OlmKeysNotSentError
24-
UtdCause.MEMBERSHIP -> Error.Name.ExpectedDueToMembership
24+
UtdCause.SENT_BEFORE_WE_JOINED -> Error.Name.ExpectedDueToMembership
25+
UtdCause.VERIFICATION_VIOLATION -> Error.Name.ExpectedVerificationViolation
26+
UtdCause.UNSIGNED_DEVICE,
27+
UtdCause.UNKNOWN_DEVICE -> {
28+
Error.Name.ExpectedSentByInsecureDevice
29+
}
2530
}
2631
val event = Error(
2732
context = null,

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomSyncSubscriber.kt

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,47 +9,27 @@ package io.element.android.libraries.matrix.impl.room
99

1010
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
1111
import io.element.android.libraries.matrix.api.core.RoomId
12-
import io.element.android.libraries.matrix.api.timeline.item.event.EventType
1312
import kotlinx.coroutines.CancellationException
1413
import kotlinx.coroutines.sync.Mutex
1514
import kotlinx.coroutines.sync.withLock
1615
import kotlinx.coroutines.withContext
17-
import org.matrix.rustcomponents.sdk.RequiredState
1816
import org.matrix.rustcomponents.sdk.RoomListService
19-
import org.matrix.rustcomponents.sdk.RoomSubscription
2017
import timber.log.Timber
2118

22-
private const val DEFAULT_TIMELINE_LIMIT = 20u
23-
2419
class RoomSyncSubscriber(
2520
private val roomListService: RoomListService,
2621
private val dispatchers: CoroutineDispatchers,
2722
) {
2823
private val subscribedRoomIds = mutableSetOf<RoomId>()
2924
private val mutex = Mutex()
3025

31-
private val settings = RoomSubscription(
32-
requiredState = listOf(
33-
RequiredState(key = EventType.STATE_ROOM_NAME, value = ""),
34-
RequiredState(key = EventType.STATE_ROOM_TOPIC, value = ""),
35-
RequiredState(key = EventType.STATE_ROOM_AVATAR, value = ""),
36-
RequiredState(key = EventType.STATE_ROOM_CANONICAL_ALIAS, value = ""),
37-
RequiredState(key = EventType.STATE_ROOM_JOIN_RULES, value = ""),
38-
RequiredState(key = EventType.STATE_ROOM_POWER_LEVELS, value = ""),
39-
RequiredState(key = EventType.STATE_ROOM_PINNED_EVENT, value = ""),
40-
),
41-
timelineLimit = DEFAULT_TIMELINE_LIMIT,
42-
// We don't need heroes here as they're already included in the `all_rooms` list
43-
includeHeroes = false,
44-
)
45-
4626
suspend fun subscribe(roomId: RoomId) {
4727
mutex.withLock {
4828
withContext(dispatchers.io) {
4929
try {
5030
if (!isSubscribedTo(roomId)) {
5131
Timber.d("Subscribing to room $roomId}")
52-
roomListService.subscribeToRooms(listOf(roomId.value), settings)
32+
roomListService.subscribeToRooms(listOf(roomId.value))
5333
}
5434
subscribedRoomIds.add(roomId)
5535
} catch (exception: Exception) {
@@ -65,7 +45,7 @@ class RoomSyncSubscriber(
6545
val roomIdsToSubscribeTo = roomIds.filterNot { isSubscribedTo(it) }
6646
if (roomIdsToSubscribeTo.isNotEmpty()) {
6747
Timber.d("Subscribing to rooms: $roomIds")
68-
roomListService.subscribeToRooms(roomIdsToSubscribeTo.map { it.value }, settings)
48+
roomListService.subscribeToRooms(roomIdsToSubscribeTo.map { it.value })
6949
subscribedRoomIds.addAll(roomIds)
7050
}
7151
} catch (cancellationException: CancellationException) {

libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/timeline/RustTimeline.kt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ class RustTimeline(
339339
formattedCaption = formattedBody?.let {
340340
FormattedBody(body = it, format = MessageFormat.Html)
341341
},
342+
storeInCache = true,
342343
progressWatcher = progressCallback?.toProgressWatcher()
343344
)
344345
}
@@ -361,6 +362,7 @@ class RustTimeline(
361362
formattedCaption = formattedBody?.let {
362363
FormattedBody(body = it, format = MessageFormat.Html)
363364
},
365+
storeInCache = true,
364366
progressWatcher = progressCallback?.toProgressWatcher()
365367
)
366368
}
@@ -374,14 +376,15 @@ class RustTimeline(
374376
// Maybe allow a caption in the future?
375377
caption = null,
376378
formattedCaption = null,
379+
storeInCache = true,
377380
progressWatcher = progressCallback?.toProgressWatcher()
378381
)
379382
}
380383
}
381384

382385
override suspend fun sendFile(file: File, fileInfo: FileInfo, progressCallback: ProgressCallback?): Result<MediaUploadHandler> {
383386
return sendAttachment(listOf(file)) {
384-
inner.sendFile(file.path, fileInfo.map(), progressCallback?.toProgressWatcher())
387+
inner.sendFile(file.path, fileInfo.map(), false, progressCallback?.toProgressWatcher())
385388
}
386389
}
387390

@@ -496,6 +499,7 @@ class RustTimeline(
496499
// Maybe allow a caption in the future?
497500
caption = null,
498501
formattedCaption = null,
502+
storeInCache = true,
499503
progressWatcher = progressCallback?.toProgressWatcher(),
500504
)
501505
}

0 commit comments

Comments
 (0)