Browse Source

Fix API break with Matrix SDK 0.1.58.

pull/1437/head
Benoit Marty 12 months ago
parent
commit
cf657df5fd
  1. 1
      libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt
  2. 1
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt
  3. 3
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RoomContentForwarder.kt
  4. 19
      libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/room/RustMatrixRoom.kt

1
libraries/matrix/api/src/main/kotlin/io/element/android/libraries/matrix/api/notification/NotificationData.kt

@ -61,6 +61,7 @@ sealed interface NotificationContent { @@ -61,6 +61,7 @@ sealed interface NotificationContent {
) : MessageLike
data object RoomRedaction : MessageLike
data object Sticker : MessageLike
data class Poll(val question: String) : MessageLike
}
sealed interface StateEvent : NotificationContent {

1
libraries/matrix/impl/src/main/kotlin/io/element/android/libraries/matrix/impl/notification/TimelineEventToNotificationContentMapper.kt

@ -94,6 +94,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon @@ -94,6 +94,7 @@ private fun MessageLikeEventContent.toContent(senderId: UserId): NotificationCon
}
MessageLikeEventContent.RoomRedaction -> NotificationContent.MessageLike.RoomRedaction
MessageLikeEventContent.Sticker -> NotificationContent.MessageLike.Sticker
is MessageLikeEventContent.Poll -> NotificationContent.MessageLike.Poll(question)
}
}
}

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

@ -27,7 +27,6 @@ import org.matrix.rustcomponents.sdk.Room @@ -27,7 +27,6 @@ import org.matrix.rustcomponents.sdk.Room
import org.matrix.rustcomponents.sdk.RoomListService
import org.matrix.rustcomponents.sdk.TimelineDiff
import org.matrix.rustcomponents.sdk.TimelineListener
import org.matrix.rustcomponents.sdk.genTransactionId
import kotlin.time.Duration.Companion.milliseconds
/**
@ -61,7 +60,7 @@ class RoomContentForwarder( @@ -61,7 +60,7 @@ class RoomContentForwarder(
// Sending a message requires a registered timeline listener
targetRoom.addTimelineListener(NoOpTimelineListener)
withTimeout(timeoutMs.milliseconds) {
targetRoom.send(content, genTransactionId())
targetRoom.send(content)
}
}
// After sending, we remove the timeline

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

@ -67,7 +67,6 @@ import org.matrix.rustcomponents.sdk.RoomMember @@ -67,7 +67,6 @@ import org.matrix.rustcomponents.sdk.RoomMember
import org.matrix.rustcomponents.sdk.RoomMessageEventContentWithoutRelation
import org.matrix.rustcomponents.sdk.RoomSubscription
import org.matrix.rustcomponents.sdk.SendAttachmentJoinHandle
import org.matrix.rustcomponents.sdk.genTransactionId
import org.matrix.rustcomponents.sdk.messageEventContentFromHtml
import org.matrix.rustcomponents.sdk.messageEventContentFromMarkdown
import timber.log.Timber
@ -241,10 +240,9 @@ class RustMatrixRoom( @@ -241,10 +240,9 @@ class RustMatrixRoom(
}
override suspend fun sendMessage(body: String, htmlBody: String?): Result<Unit> = withContext(roomDispatcher) {
val transactionId = genTransactionId()
messageEventContentFromParts(body, htmlBody).use { content ->
runCatching {
innerRoom.send(content, transactionId)
innerRoom.send(content)
}
}
}
@ -253,26 +251,27 @@ class RustMatrixRoom( @@ -253,26 +251,27 @@ class RustMatrixRoom(
withContext(roomDispatcher) {
if (originalEventId != null) {
runCatching {
innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value, transactionId?.value)
innerRoom.edit(messageEventContentFromParts(body, htmlBody), originalEventId.value)
}
} else {
runCatching {
transactionId?.let { cancelSend(it) }
innerRoom.send(messageEventContentFromParts(body, htmlBody), genTransactionId())
innerRoom.send(messageEventContentFromParts(body, htmlBody))
}
}
}
override suspend fun replyMessage(eventId: EventId, body: String, htmlBody: String?): Result<Unit> = withContext(roomDispatcher) {
runCatching {
innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventId.value, genTransactionId())
innerRoom.getEventTimelineItemByEventId(eventId.value).use { eventTimelineItem ->
innerRoom.sendReply(messageEventContentFromParts(body, htmlBody), eventTimelineItem)
}
}
}
override suspend fun redactEvent(eventId: EventId, reason: String?) = withContext(roomDispatcher) {
val transactionId = genTransactionId()
runCatching {
innerRoom.redact(eventId.value, reason, transactionId)
innerRoom.redact(eventId.value, reason)
}
}
@ -416,7 +415,6 @@ class RustMatrixRoom( @@ -416,7 +415,6 @@ class RustMatrixRoom(
description = description,
zoomLevel = zoomLevel?.toUByte(),
assetType = assetType?.toInner(),
txnId = genTransactionId(),
)
}
}
@ -433,7 +431,6 @@ class RustMatrixRoom( @@ -433,7 +431,6 @@ class RustMatrixRoom(
answers = answers,
maxSelections = maxSelections.toUByte(),
pollKind = pollKind.toInner(),
txnId = genTransactionId(),
)
}
}
@ -446,7 +443,6 @@ class RustMatrixRoom( @@ -446,7 +443,6 @@ class RustMatrixRoom(
innerRoom.sendPollResponse(
pollStartId = pollStartId.value,
answers = answers,
txnId = genTransactionId(),
)
}
}
@ -459,7 +455,6 @@ class RustMatrixRoom( @@ -459,7 +455,6 @@ class RustMatrixRoom(
innerRoom.endPoll(
pollStartId = pollStartId.value,
text = text,
txnId = genTransactionId(),
)
}
}

Loading…
Cancel
Save